feat: Add support for not requiring SMTP auth with user management (#3742)

This commit is contained in:
Xavier Calland 2023-08-15 10:55:58 +02:00 committed by GitHub
parent 3adb0b66ea
commit eead6d49f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View file

@ -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 {

View file

@ -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<void> {
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<void> {