diff --git a/packages/nodes-base/nodes/EmailReadImap.node.ts b/packages/nodes-base/nodes/EmailReadImap.node.ts index 57d3a3f6f0..aa976970c4 100644 --- a/packages/nodes-base/nodes/EmailReadImap.node.ts +++ b/packages/nodes-base/nodes/EmailReadImap.node.ts @@ -8,7 +8,7 @@ import { ITriggerResponse, } from 'n8n-workflow'; -import { connect as imapConnect, ImapSimple, getParts, Message } from 'imap-simple'; +import { connect as imapConnect, ImapSimple, ImapSimpleOptions, getParts, Message } from 'imap-simple'; export class EmailReadImap implements INodeType { description: INodeTypeDescription = { @@ -75,6 +75,22 @@ export class EmailReadImap implements INodeType { }, description: 'Prefix for name of the binary property to which to
write the attachments. An index starting with 0 will be added.
So if name is "attachment_" the first attachment is saved to "attachment_0"', }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Option', + default: {}, + options: [ + { + displayName: 'Ignore SSL Issues', + name: 'allowUnauthorizedCerts', + type: 'boolean', + default: false, + description: 'Do connect even if SSL certificate validation is not possible.', + }, + ], + }, ], }; @@ -90,6 +106,7 @@ export class EmailReadImap implements INodeType { const mailbox = this.getNodeParameter('mailbox') as string; const postProcessAction = this.getNodeParameter('postProcessAction') as string; const downloadAttachments = this.getNodeParameter('downloadAttachments') as boolean; + const options = this.getNodeParameter('options', {}) as IDataObject; // Returns the email text @@ -219,7 +236,7 @@ export class EmailReadImap implements INodeType { let connection: ImapSimple; - const config = { + const config: ImapSimpleOptions = { imap: { user: credentials.user as string, password: credentials.password as string, @@ -237,6 +254,12 @@ export class EmailReadImap implements INodeType { }, }; + if (options.allowUnauthorizedCerts === true) { + config.imap.tlsOptions = { + rejectUnauthorized: false + }; + } + // Connect to the IMAP server and open the mailbox // that we get informed whenever a new email arrives connection = await imapConnect(config); diff --git a/packages/nodes-base/nodes/EmailSend.node.ts b/packages/nodes-base/nodes/EmailSend.node.ts index 0e73bb2e87..aee5054bcd 100644 --- a/packages/nodes-base/nodes/EmailSend.node.ts +++ b/packages/nodes-base/nodes/EmailSend.node.ts @@ -3,13 +3,14 @@ import { IExecuteSingleFunctions, } from 'n8n-core'; import { + IDataObject, INodeTypeDescription, INodeExecutionData, INodeType, } from 'n8n-workflow'; import { createTransport } from 'nodemailer'; - +import SMTPTransport = require('nodemailer/lib/smtp-transport'); export class EmailSend implements INodeType { description: INodeTypeDescription = { @@ -96,6 +97,22 @@ export class EmailSend implements INodeType { default: '', description: 'Name of the binary properties which contain
data which should be added to email as attachment.
Multiple ones can be comma separated.', }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Option', + default: {}, + options: [ + { + displayName: 'Ignore SSL Issues', + name: 'allowUnauthorizedCerts', + type: 'boolean', + default: false, + description: 'Do connect even if SSL certificate validation is not possible.', + }, + ], + }, ], }; @@ -110,6 +127,7 @@ export class EmailSend implements INodeType { const text = this.getNodeParameter('text') as string; const html = this.getNodeParameter('html') as string; const attachmentPropertyString = this.getNodeParameter('attachments') as string; + const options = this.getNodeParameter('options', {}) as IDataObject; const credentials = this.getCredentials('smtp'); @@ -117,16 +135,24 @@ export class EmailSend implements INodeType { throw new Error('No credentials got returned!'); } - const transporter = createTransport({ - // @ts-ignore + const connectionOptions: SMTPTransport.Options = { host: credentials.host as string, port: credentials.port as number, secure: credentials.secure as boolean, + // @ts-ignore auth: { user: credentials.user, pass: credentials.password, } - }); + }; + + if (options.allowUnauthorizedCerts === true) { + connectionOptions.tls = { + rejectUnauthorized: false + }; + } + + const transporter = createTransport(connectionOptions); // setup email data with unicode symbols const mailOptions = {