mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(Send Email Node): Smtp credential improvements (#10147)
This commit is contained in:
parent
ada1256898
commit
dc13ceb416
|
@ -41,6 +41,17 @@ export class Smtp implements ICredentialType {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Disable STARTTLS',
|
||||||
|
name: 'disableStartTls',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
secure: [false],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Client Host Name',
|
displayName: 'Client Host Name',
|
||||||
name: 'hostName',
|
name: 'hostName',
|
||||||
|
|
|
@ -26,6 +26,7 @@ const versionDescription: INodeTypeDescription = {
|
||||||
{
|
{
|
||||||
name: 'smtp',
|
name: 'smtp',
|
||||||
required: true,
|
required: true,
|
||||||
|
testedBy: 'smtpConnectionTest',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
|
@ -70,6 +71,10 @@ export class EmailSendV2 implements INodeType {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
methods = {
|
||||||
|
credentialTest: { smtpConnectionTest: send.smtpConnectionTest },
|
||||||
|
};
|
||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
let returnData: INodeExecutionData[][] = [];
|
let returnData: INodeExecutionData[][] = [];
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import type {
|
import type {
|
||||||
|
ICredentialsDecrypted,
|
||||||
|
ICredentialTestFunctions,
|
||||||
IDataObject,
|
IDataObject,
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
|
INodeCredentialTestResult,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
JsonObject,
|
JsonObject,
|
||||||
|
@ -210,6 +213,10 @@ function configureTransport(credentials: IDataObject, options: EmailSendOptions)
|
||||||
secure: credentials.secure as boolean,
|
secure: credentials.secure as boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (credentials.secure === false) {
|
||||||
|
connectionOptions.ignoreTLS = credentials.disableStartTls as boolean;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof credentials.hostName === 'string' && credentials.hostName) {
|
if (typeof credentials.hostName === 'string' && credentials.hostName) {
|
||||||
connectionOptions.name = credentials.hostName;
|
connectionOptions.name = credentials.hostName;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +237,28 @@ function configureTransport(credentials: IDataObject, options: EmailSendOptions)
|
||||||
return createTransport(connectionOptions);
|
return createTransport(connectionOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function smtpConnectionTest(
|
||||||
|
this: ICredentialTestFunctions,
|
||||||
|
credential: ICredentialsDecrypted,
|
||||||
|
): Promise<INodeCredentialTestResult> {
|
||||||
|
const credentials = credential.data!;
|
||||||
|
const transporter = configureTransport(credentials, {});
|
||||||
|
try {
|
||||||
|
await transporter.verify();
|
||||||
|
return {
|
||||||
|
status: 'OK',
|
||||||
|
message: 'Connection successful!',
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
status: 'Error',
|
||||||
|
message: error.message,
|
||||||
|
};
|
||||||
|
} finally {
|
||||||
|
transporter.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
export async function execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
const nodeVersion = this.getNode().typeVersion;
|
const nodeVersion = this.getNode().typeVersion;
|
||||||
|
|
Loading…
Reference in a new issue