mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Make it possible to use email nodes work with unauthorized certs
This commit is contained in:
@@ -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<br />data which should be added to email as attachment.<br />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 = {
|
||||
|
||||
Reference in New Issue
Block a user