Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 allow smtp settings without credentials #364 #389

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions helpers/functions/nodemailerSMTP.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
//Lib
import nodemailer from 'nodemailer';

export default function nodemailerSMTP() {
const transporter = nodemailer.createTransport({
const config = {
port: parseInt(process.env.MAIL_SMTP_PORT, 10),
host: process.env.MAIL_SMTP_HOST,
auth: {
user: process.env.MAIL_SMTP_LOGIN || '',
pass: process.env.MAIL_SMTP_PWD || '',
},
tls: {
// false value allow self-signed or invalid TLS certificate
rejectUnauthorized: process.env.MAIL_REJECT_SELFSIGNED_TLS === 'false' ? false : true,
},
});
};

const smtpLogin = process.env.MAIL_SMTP_LOGIN || '';
const smtpPwd = process.env.MAIL_SMTP_PWD || '';

// Some SMTP servers doesn't require authentication #364
if (smtpLogin) {
config.auth = {
user: smtpLogin,
pass: smtpPwd,
};
}

const transporter = nodemailer.createTransport(config);
return transporter;
}
Loading