From e28057459f235fe06088c363f9ef3970f8167fca Mon Sep 17 00:00:00 2001 From: Xavier Calland Date: Wed, 20 Jul 2022 14:11:47 +0200 Subject: [PATCH 1/3] Allow SMTP configuration without auth - do not check for user/pass in isEmailSetUp - do not pass an "auth" property to nodemailer if no user/pass Issue: #3740 --- .../cli/src/UserManagement/UserManagementHelper.ts | 4 +--- .../cli/src/UserManagement/email/NodeMailer.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/UserManagement/UserManagementHelper.ts b/packages/cli/src/UserManagement/UserManagementHelper.ts index cc4df147fd884..5143f7917aa08 100644 --- a/packages/cli/src/UserManagement/UserManagementHelper.ts +++ b/packages/cli/src/UserManagement/UserManagementHelper.ts @@ -26,10 +26,8 @@ export async function getWorkflowOwner(workflowId: string | number): Promise { From 59b68303d7e61aec780c18841cd92c493b1bf2f8 Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Mon, 14 Aug 2023 15:30:27 +0100 Subject: [PATCH 2/3] Quick tweak --- packages/cli/src/UserManagement/email/NodeMailer.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/UserManagement/email/NodeMailer.ts b/packages/cli/src/UserManagement/email/NodeMailer.ts index e5a998e9ee0e1..2e08e8c233b80 100644 --- a/packages/cli/src/UserManagement/email/NodeMailer.ts +++ b/packages/cli/src/UserManagement/email/NodeMailer.ts @@ -1,19 +1,21 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import type { Transporter } from 'nodemailer'; import { createTransport } from 'nodemailer'; +import type { IDataObject } from 'n8n-workflow'; import { ErrorReporterProxy as ErrorReporter, LoggerProxy as Logger } from 'n8n-workflow'; import config from '@/config'; import type { MailData, SendEmailResult } from './Interfaces'; export class NodeMailer { - private transport?: Transporter; + private transport: Transporter; - constructor() { - const transportConfig: any = { + async init(): Promise { + const transportConfig: IDataObject = { host: config.getEnv('userManagement.emails.smtp.host'), port: config.getEnv('userManagement.emails.smtp.port'), secure: config.getEnv('userManagement.emails.smtp.secure'), }; + if ( config.getEnv('userManagement.emails.smtp.auth.user') && config.getEnv('userManagement.emails.smtp.auth.pass') @@ -23,6 +25,7 @@ export class NodeMailer { pass: config.getEnv('userManagement.emails.smtp.auth.pass'), }; } + this.transport = createTransport(transportConfig); } From 0f38e40b08b9cce3f6bb321bc7992d4156e1329f Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Tue, 15 Aug 2023 09:37:01 +0100 Subject: [PATCH 3/3] Remove IDataObject --- packages/cli/src/UserManagement/email/NodeMailer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/UserManagement/email/NodeMailer.ts b/packages/cli/src/UserManagement/email/NodeMailer.ts index 2e08e8c233b80..fbf58ca4b6a41 100644 --- a/packages/cli/src/UserManagement/email/NodeMailer.ts +++ b/packages/cli/src/UserManagement/email/NodeMailer.ts @@ -1,16 +1,16 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import type { Transporter } from 'nodemailer'; import { createTransport } from 'nodemailer'; -import type { IDataObject } from 'n8n-workflow'; import { ErrorReporterProxy as ErrorReporter, LoggerProxy as Logger } from 'n8n-workflow'; import config from '@/config'; import type { MailData, SendEmailResult } from './Interfaces'; +import type SMTPConnection from 'nodemailer/lib/smtp-connection'; export class NodeMailer { - private transport: Transporter; + private transport?: Transporter; async init(): Promise { - const transportConfig: IDataObject = { + const transportConfig: SMTPConnection.Options = { host: config.getEnv('userManagement.emails.smtp.host'), port: config.getEnv('userManagement.emails.smtp.port'), secure: config.getEnv('userManagement.emails.smtp.secure'),