diff --git a/lib/private/mail/send.js b/lib/private/mail/send.js index 07b2903..30450c6 100644 --- a/lib/private/mail/send.js +++ b/lib/private/mail/send.js @@ -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: @@ -82,13 +82,13 @@ module.exports = { 'An override for the default "from" email that\'s been configured.', example: 'anne.martin@example.com', 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: { @@ -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 } }) @@ -227,14 +227,14 @@ 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}>`, @@ -242,7 +242,7 @@ module.exports = { subject, html }) - sails.log.debug('Message sent: %s', resendInfo.id) + sails.log.debug('Email sent: %s', resendInfo.id) break case 'log': const logMessage = ` diff --git a/package.json b/package.json index bf4e256..25b9ad5 100644 --- a/package.json +++ b/package.json @@ -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": {