Skip to content

Commit

Permalink
feat: make config in local.js match config/mail.js (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin authored Mar 18, 2024
1 parent 1c5d557 commit 9c8994a
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/private/mail/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ module.exports = {
description: 'The mailer to used.',
extendedDescription:
'The mailer should be configured properly in config/mails.js. If not specified, the default mailer in sails.config.mail.default will be used',
defaultsTo:
sails.config.mailer ||
sails.config.mail.default ||
process.env.MAIL_MAILER
defaultsTo: process.env.MAIL_MAILER || sails.config.mail.default
},
template: {
description:
Expand Down Expand Up @@ -190,25 +187,18 @@ module.exports = {
const nodemailer = getModule('nodemailer')
var transporter = nodemailer.createTransport({
host:
sails.config[mailer]?.host ||
sails.config.mail.mailers[mailer]?.host ||
process.env.MAIL_HOST,
sails.config.mail.mailers[mailer]?.host || process.env.MAIL_HOST,
port:
sails.config[mailer]?.port ||
sails.config.mail.mailers[mailer]?.port ||
process.env.MAIL_PORT,
sails.config.mail.mailers[mailer]?.port || process.env.MAIL_PORT,
secure:
sails.config[mailer]?.secure ||
sails.config.mail.mailers[mailer]?.secure ||
process.env.MAIL_SECURE ||
false,
auth: {
user:
sails.config[mailer]?.username ||
sails.config.mail.mailers[mailer]?.username ||
process.env.MAIL_USERNAME,
pass:
sails.config[mailer]?.password ||
sails.config.mail.mailers[mailer]?.password ||
process.env.MAIL_PASSWORD
}
Expand All @@ -232,7 +222,6 @@ module.exports = {
case 'resend':
const { Resend } = getModule('resend')
const apiKey =
sails.config[mailer]?.apiKey ||
sails.config.mail.mailers[mailer]?.apiKey ||
process.env.RESEND_API_KEY
const resend = new Resend(apiKey)
Expand Down

0 comments on commit 9c8994a

Please sign in to comment.