From 45768a7e6cf390e7854841f0b86da5be22d4adc7 Mon Sep 17 00:00:00 2001 From: Eric Carraway Date: Fri, 30 Sep 2022 14:57:12 -0400 Subject: [PATCH] Update `mailgun.sendHtmlEmail` to support `bcc` --- lib/private/mailgun/send-html-email.js | 28 +++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/private/mailgun/send-html-email.js b/lib/private/mailgun/send-html-email.js index 47ff2c9..e3228eb 100644 --- a/lib/private/mailgun/send-html-email.js +++ b/lib/private/mailgun/send-html-email.js @@ -44,6 +44,13 @@ module.exports = { example: 'Sails Co.' }, + bcc: { + description: + 'A list of email addresses of recipients secretly copied on the email.', + example: ['jahnna.n.malcolm@example.com'], + defaultsTo: [], + }, + secret: { type: 'string', required: true, @@ -117,9 +124,20 @@ module.exports = { }, - - fn: async function({to, subject, htmlMessage, from, fromName, secret, domain, host, toName, textMessage, testMode}) { - + fn: async function ({ + to, + subject, + htmlMessage, + from, + fromName, + bcc, + secret, + domain, + host, + toName, + textMessage, + testMode, + }) { // Import dependencies. var Http = require('machinepack-http'); @@ -151,6 +169,10 @@ module.exports = { html: htmlMessage || '', }; + if (Array.isArray(bcc) && bcc.length) { + data.bcc = bcc.join(','); + } + if(testMode) { data['o:testmode'] = 'yes'; }