Allow anonymous SMTP connections (#59)

This adds support for anonymously connecting to SMTP servers
that do not require authentication; if a username is not provided,
it will not attempt to authenticate.
This commit is contained in:
P. J. Reed
2020-05-19 15:21:07 -05:00
committed by GitHub
parent 3ce40c51a6
commit 8ddbec6b68

View File

@@ -34,8 +34,9 @@ module.exports = {
console.log("Email: to " + to_email + " in production.\nreply_to: " + reply_to + "\nsubject: " + subject + "\nbody: \n" + htmlText + "\n\n plaintext:\n" + plaintext);
} else if (config.get('mail_provider') === 'smtp') {
const transporter = nodemailer.createTransport({
let transporter;
if (config.has('mail_smtp_user')) {
transporter = nodemailer.createTransport({
host: config.get('mail_smtp_host'),
port: config.get('mail_smtp_port'),
secure: config.get('mail_smtp_secure'),
@@ -45,6 +46,15 @@ module.exports = {
pass: config.get('mail_smtp_pass'),
}
});
} else {
transporter = nodemailer.createTransport({
host: config.get('mail_smtp_host'),
port: config.get('mail_smtp_port'),
secure: config.get('mail_smtp_secure'),
requireTLS: config.get('mail_smtp_require_tls'),
});
}
transporter.sendMail({
from: from,