Allow nodemailer SMTP configuration with no authentication (#5673)

* Allow nodemailer SMTP configuration with no authentication

* Fix typing + use or instead of and for user/pass combo

Co-authored-by: Fady Khalife <fady.khalife@yakkazoo.com>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Fady Khalife
2021-05-15 01:01:32 +10:00
committed by GitHub
parent 6fd6bf9150
commit 8fc8da62a7

View File

@@ -11,16 +11,22 @@ if (env.EMAIL_TRANSPORT === 'sendmail') {
path: env.EMAIL_SENDMAIL_PATH || '/usr/sbin/sendmail',
});
} else if (env.EMAIL_TRANSPORT.toLowerCase() === 'smtp') {
let auth: boolean | { user?: string; pass?: string } = false;
if (env.EMAIL_SMTP_USER || env.EMAIL_SMTP_PASSWORD) {
auth = {
user: env.EMAIL_SMTP_USER,
pass: env.EMAIL_SMTP_PASSWORD,
};
}
transporter = nodemailer.createTransport({
pool: env.EMAIL_SMTP_POOL,
host: env.EMAIL_SMTP_HOST,
port: env.EMAIL_SMTP_PORT,
secure: env.EMAIL_SMTP_SECURE,
auth: {
user: env.EMAIL_SMTP_USER,
pass: env.EMAIL_SMTP_PASSWORD,
},
} as any);
auth: auth,
} as Record<string, unknown>);
} else {
logger.warn('Illegal transport given for email. Check the EMAIL_TRANSPORT env var.');
}