diff --git a/packages/cli/src/UserManagement/UserManagementHelper.ts b/packages/cli/src/UserManagement/UserManagementHelper.ts index 14efff5e16..5c119df0de 100644 --- a/packages/cli/src/UserManagement/UserManagementHelper.ts +++ b/packages/cli/src/UserManagement/UserManagementHelper.ts @@ -16,10 +16,8 @@ import { RoleService } from '@/services/role.service'; export function isEmailSetUp(): boolean { const smtp = config.getEnv('userManagement.emails.mode') === 'smtp'; const host = !!config.getEnv('userManagement.emails.smtp.host'); - const user = !!config.getEnv('userManagement.emails.smtp.auth.user'); - const pass = !!config.getEnv('userManagement.emails.smtp.auth.pass'); - return smtp && host && user && pass; + return smtp && host; } export function isSharingEnabled(): boolean { diff --git a/packages/cli/src/UserManagement/email/NodeMailer.ts b/packages/cli/src/UserManagement/email/NodeMailer.ts index 32ee1b0238..fbf58ca4b6 100644 --- a/packages/cli/src/UserManagement/email/NodeMailer.ts +++ b/packages/cli/src/UserManagement/email/NodeMailer.ts @@ -4,20 +4,29 @@ import { createTransport } from 'nodemailer'; 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; async init(): Promise { - this.transport = createTransport({ + 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'), - auth: { + }; + + if ( + config.getEnv('userManagement.emails.smtp.auth.user') && + config.getEnv('userManagement.emails.smtp.auth.pass') + ) { + transportConfig.auth = { user: config.getEnv('userManagement.emails.smtp.auth.user'), pass: config.getEnv('userManagement.emails.smtp.auth.pass'), - }, - }); + }; + } + + this.transport = createTransport(transportConfig); } async verifyConnection(): Promise {