Make optional use of STARTTLS possible if required.

This commit is contained in:
gluap 2021-06-30 22:01:01 +02:00 committed by Paul Bienkowski
parent e52575ab87
commit 4c28187741
3 changed files with 6 additions and 3 deletions

View file

@ -7,7 +7,8 @@
"from": "Sender Name <sender@example.com>",
"smtp" : {
"host": "mail.example.com",
"port": 587,
"port": 465,
"starttls": false,
"username": "sender@example.com",
"password": "hunter2"
}

View file

@ -10,7 +10,8 @@ async function sendEmail({ to, subject, html }) {
const transporter = nodemailer.createTransport({
host: config.mail.smtp.host,
port: config.mail.smtp.port,
secure: true,
secure: !config.mail.smtp.starttls,
requiretls: config.mail.smtp.starttls,
auth: {
user: config.mail.smtp.username,
pass: config.mail.smtp.password,

View file

@ -16,7 +16,8 @@ const configSchema = Joi.object({
from: Joi.string().required(),
smtp: Joi.object({
host: Joi.string().required(),
port: Joi.number().default(587),
port: Joi.number().default(465),
starttls: Joi.boolean().default(false),
username: Joi.string().required(),
password: Joi.string().required(),
}).required(),