Skip to content

Commit

Permalink
Merge branch 'release/0.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Mar 1, 2024
2 parents af3cee7 + 3c038bb commit 32c5bb5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions lib/private/mail/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module.exports = {
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:
process.env.MAIL_MAILER ||
sails.config.mailer ||
sails.config.mail.default
sails.config.mail.default ||
process.env.MAIL_MAILER
},
template: {
description:
Expand Down Expand Up @@ -82,13 +82,13 @@ module.exports = {
'An override for the default "from" email that\'s been configured.',
example: '[email protected]',
isEmail: true,
defaultsTo: process.env.MAIL_FROM_ADRESS || sails.config.mail.from.address
defaultsTo: sails.config.mail.from.address || process.env.MAIL_FROM_ADRESS
},

fromName: {
description: 'An override for the default "from" name.',
example: 'Anne Martin',
defaultsTo: process.env.MAIL_FROM_NAME || sails.config.mail.from.name
defaultsTo: sails.config.mail.from.name || process.env.MAIL_FROM_NAME
},

layout: {
Expand Down Expand Up @@ -190,27 +190,27 @@ module.exports = {
const nodemailer = getModule('nodemailer')
var transporter = nodemailer.createTransport({
host:
process.env.MAIL_HOST ||
sails.config[mailer]?.host ||
sails.config.mail.mailers[mailer]?.host,
sails.config.mail.mailers[mailer]?.host ||
process.env.MAIL_HOST,
port:
process.env.MAIL_PORT ||
sails.config[mailer]?.port ||
sails.config.mail.mailers[mailer]?.port,
sails.config.mail.mailers[mailer]?.port ||
process.env.MAIL_PORT,
secure:
process.env.MAIL_SECURE ||
sails.config[mailer]?.secure ||
sails.config.mail.mailers[mailer]?.secure ||
process.env.MAIL_SECURE ||
false,
auth: {
user:
process.env.MAIL_USERNAME ||
sails.config[mailer]?.username ||
sails.config.mail.mailers[mailer]?.username,
sails.config.mail.mailers[mailer]?.username ||
process.env.MAIL_USERNAME,
pass:
process.env.MAIL_PASSWORD ||
sails.config[mailer]?.password ||
sails.config.mail.mailers[mailer]?.password
sails.config.mail.mailers[mailer]?.password ||
process.env.MAIL_PASSWORD
}
})

Expand All @@ -227,22 +227,22 @@ module.exports = {
bcc,
attachments
})
sails.log.debug('Message sent: %s', smtpInfo.messageId)
sails.log.debug('Email sent: %s', smtpInfo.messageId)
break
case 'resend':
const { Resend } = getModule('resend')
const apiKey =
process.env.RESEND_API_KEY ||
sails.config[mailer]?.apiKey ||
sails.config.mail.mailers[mailer]?.apiKey
sails.config.mail.mailers[mailer]?.apiKey ||
process.env.RESEND_API_KEY
const resend = new Resend(apiKey)
const resendInfo = await resend.emails.send({
from: `${fromName} <${fromAddress}>`,
to,
subject,
html
})
sails.log.debug('Message sent: %s', resendInfo.id)
sails.log.debug('Email sent: %s', resendInfo.id)
break
case 'log':
const logMessage = `
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sails-hook-mail",
"version": "0.0.8",
"version": "0.0.9",
"description": "The simple elegant way to send emails from a Sails application",
"main": "lib/sails-hook-mail.js",
"scripts": {
Expand Down

0 comments on commit 32c5bb5

Please sign in to comment.