Skip to content

Commit

Permalink
Merge branch 'release/0.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Sep 6, 2023
2 parents a238fdf + 3b288a0 commit 89576d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions lib/private/mail/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ module.exports = {
'An override for the default "from" email that\'s been configured.',
example: '[email protected]',
isEmail: true,
defaultsTo: sails.config.mail.from.address || process.env.MAIL_FROM_ADRESS
defaultsTo: process.env.MAIL_FROM_ADRESS || sails.config.mail.from.address
},

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

layout: {
Expand Down Expand Up @@ -165,32 +165,32 @@ module.exports = {
err.message
return err
})
switch (sails.config.mail.mailers[mailer].transport) {
switch (sails.config.mail.mailers[mailer]?.transport) {
case 'smtp':
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[mailer]?.host ||
sails.config.mail.mailers[mailer]?.host,
port:
process.env.MAIL_PORT ||
sails.config[mailer].port ||
sails.config.mail.mailers[mailer].port,
sails.config[mailer]?.port ||
sails.config.mail.mailers[mailer]?.port,
secure:
process.env.MAIL_SECURE ||
sails.config[mailer].secure ||
sails.config.mail.mailers[mailer].secure ||
sails.config[mailer]?.secure ||
sails.config.mail.mailers[mailer]?.secure ||
false,
auth: {
user:
process.env.MAIL_USERNAME ||
sails.config[mailer].username ||
sails.config.mail.mailers[mailer].username,
sails.config[mailer]?.username ||
sails.config.mail.mailers[mailer]?.username,
pass:
process.env.MAIL_PASSWORD ||
sails.config[mailer].password ||
sails.config.mail.mailers[mailer].password
sails.config[mailer]?.password ||
sails.config.mail.mailers[mailer]?.password
}
})

Expand All @@ -210,8 +210,8 @@ module.exports = {
const { Resend } = getModule('resend')
const apiKey =
process.env.RESEND_API_KEY ||
sails.config[mailer].apiKey ||
sails.config.mail.mailers[mailer].apiKey
sails.config[mailer]?.apiKey ||
sails.config.mail.mailers[mailer]?.apiKey
const resend = new Resend(apiKey)
const resendInfo = await resend.emails.send({
from: `${fromName} <${fromAddress}>`,
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.5",
"version": "0.0.6",
"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 89576d2

Please sign in to comment.