mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -08:00
feat: Add support for not requiring SMTP auth with user management (#3742)
This commit is contained in:
parent
3adb0b66ea
commit
eead6d49f2
|
@ -16,10 +16,8 @@ import { RoleService } from '@/services/role.service';
|
||||||
export function isEmailSetUp(): boolean {
|
export function isEmailSetUp(): boolean {
|
||||||
const smtp = config.getEnv('userManagement.emails.mode') === 'smtp';
|
const smtp = config.getEnv('userManagement.emails.mode') === 'smtp';
|
||||||
const host = !!config.getEnv('userManagement.emails.smtp.host');
|
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 {
|
export function isSharingEnabled(): boolean {
|
||||||
|
|
|
@ -4,20 +4,29 @@ import { createTransport } from 'nodemailer';
|
||||||
import { ErrorReporterProxy as ErrorReporter, LoggerProxy as Logger } from 'n8n-workflow';
|
import { ErrorReporterProxy as ErrorReporter, LoggerProxy as Logger } from 'n8n-workflow';
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import type { MailData, SendEmailResult } from './Interfaces';
|
import type { MailData, SendEmailResult } from './Interfaces';
|
||||||
|
import type SMTPConnection from 'nodemailer/lib/smtp-connection';
|
||||||
|
|
||||||
export class NodeMailer {
|
export class NodeMailer {
|
||||||
private transport?: Transporter;
|
private transport?: Transporter;
|
||||||
|
|
||||||
async init(): Promise<void> {
|
async init(): Promise<void> {
|
||||||
this.transport = createTransport({
|
const transportConfig: SMTPConnection.Options = {
|
||||||
host: config.getEnv('userManagement.emails.smtp.host'),
|
host: config.getEnv('userManagement.emails.smtp.host'),
|
||||||
port: config.getEnv('userManagement.emails.smtp.port'),
|
port: config.getEnv('userManagement.emails.smtp.port'),
|
||||||
secure: config.getEnv('userManagement.emails.smtp.secure'),
|
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'),
|
user: config.getEnv('userManagement.emails.smtp.auth.user'),
|
||||||
pass: config.getEnv('userManagement.emails.smtp.auth.pass'),
|
pass: config.getEnv('userManagement.emails.smtp.auth.pass'),
|
||||||
},
|
};
|
||||||
});
|
}
|
||||||
|
|
||||||
|
this.transport = createTransport(transportConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
async verifyConnection(): Promise<void> {
|
async verifyConnection(): Promise<void> {
|
||||||
|
|
Loading…
Reference in a new issue