From 509682cd6a68294b16f32f43fba2c831f5951f48 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Wed, 6 Nov 2019 17:50:41 +0700 Subject: [PATCH] Supported unsubscribe_url template variable for bulk email no-issue --- core/server/services/bulk-email/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/server/services/bulk-email/index.js b/core/server/services/bulk-email/index.js index de48c8ad30..c9da487659 100644 --- a/core/server/services/bulk-email/index.js +++ b/core/server/services/bulk-email/index.js @@ -19,13 +19,16 @@ module.exports = { /** * @param {Email} message - The message to send * @param {[EmailAddress]} recipients - the recipients to send the email to + * @param {[object]} recipientData - list of data keyed by email to inject into the email * @returns {Promise} A promise representing the success of the email sending */ - async send(message, recipients) { + async send(message, recipients, recipientData) { for (const recipient of recipients) { const messageToSend = Object.assign({}, message, { to: recipient }); + const unsubscribeUrl = recipientData[recipient].unsubscribe_url; + messageToSend.html = messageToSend.html.replace('%recipient.unsubscribe_url%', unsubscribeUrl); try { await ghostMailer.send(messageToSend); } catch (err) {