From 70f5e6962af46752d56cf9e19cc7b71891ff8fa0 Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Fri, 1 Mar 2024 14:25:23 +0100 Subject: [PATCH 1/5] feat: switch credentials look up (#14) --- lib/private/mail/send.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) 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 = ` From 4fa827e4fd8a1ae55a0a5d1ab1669d6e4467640c Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Fri, 1 Mar 2024 14:26:20 +0100 Subject: [PATCH 2/5] chore: release 0.0.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": { From 1c5d5575517fbb2988da8ed0a81c2028e128dae1 Mon Sep 17 00:00:00 2001 From: Lennox Charles Date: Mon, 18 Mar 2024 19:37:51 +0100 Subject: [PATCH 3/5] fix typo send.js file (#16) This PR fixes #15 --- lib/private/mail/send.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/mail/send.js b/lib/private/mail/send.js index 30450c6..d4c5360 100644 --- a/lib/private/mail/send.js +++ b/lib/private/mail/send.js @@ -82,7 +82,7 @@ module.exports = { 'An override for the default "from" email that\'s been configured.', example: 'anne.martin@example.com', isEmail: true, - defaultsTo: sails.config.mail.from.address || process.env.MAIL_FROM_ADRESS + defaultsTo: sails.config.mail.from.address || process.env.MAIL_FROM_ADDRESS }, fromName: { From 9c8994ae04f257394009a4764a81a2a03a4a2d3f Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Mon, 18 Mar 2024 19:49:52 +0100 Subject: [PATCH 4/5] feat: make config in local.js match config/mail.js (#18) --- lib/private/mail/send.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/private/mail/send.js b/lib/private/mail/send.js index d4c5360..4ffc93b 100644 --- a/lib/private/mail/send.js +++ b/lib/private/mail/send.js @@ -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: @@ -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 } @@ -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) From 3f6221410bde0c39f96c0a861d7b5da8d25213c1 Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Mon, 18 Mar 2024 19:51:21 +0100 Subject: [PATCH 5/5] chore: release 0.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 25b9ad5..1a9383a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sails-hook-mail", - "version": "0.0.9", + "version": "0.1.0", "description": "The simple elegant way to send emails from a Sails application", "main": "lib/sails-hook-mail.js", "scripts": {