Make optional use of STARTTLS possible if required.
This commit is contained in:
parent
e52575ab87
commit
4c28187741
3 changed files with 6 additions and 3 deletions
|
@ -7,7 +7,8 @@
|
||||||
"from": "Sender Name <sender@example.com>",
|
"from": "Sender Name <sender@example.com>",
|
||||||
"smtp" : {
|
"smtp" : {
|
||||||
"host": "mail.example.com",
|
"host": "mail.example.com",
|
||||||
"port": 587,
|
"port": 465,
|
||||||
|
"starttls": false,
|
||||||
"username": "sender@example.com",
|
"username": "sender@example.com",
|
||||||
"password": "hunter2"
|
"password": "hunter2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,8 @@ async function sendEmail({ to, subject, html }) {
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
host: config.mail.smtp.host,
|
host: config.mail.smtp.host,
|
||||||
port: config.mail.smtp.port,
|
port: config.mail.smtp.port,
|
||||||
secure: true,
|
secure: !config.mail.smtp.starttls,
|
||||||
|
requiretls: config.mail.smtp.starttls,
|
||||||
auth: {
|
auth: {
|
||||||
user: config.mail.smtp.username,
|
user: config.mail.smtp.username,
|
||||||
pass: config.mail.smtp.password,
|
pass: config.mail.smtp.password,
|
||||||
|
|
|
@ -16,7 +16,8 @@ const configSchema = Joi.object({
|
||||||
from: Joi.string().required(),
|
from: Joi.string().required(),
|
||||||
smtp: Joi.object({
|
smtp: Joi.object({
|
||||||
host: Joi.string().required(),
|
host: Joi.string().required(),
|
||||||
port: Joi.number().default(587),
|
port: Joi.number().default(465),
|
||||||
|
starttls: Joi.boolean().default(false),
|
||||||
username: Joi.string().required(),
|
username: Joi.string().required(),
|
||||||
password: Joi.string().required(),
|
password: Joi.string().required(),
|
||||||
}).required(),
|
}).required(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue