0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Supported unsubscribe_url template variable for bulk email

no-issue
This commit is contained in:
Fabien O'Carroll 2019-11-06 17:50:41 +07:00
parent 00db1d385c
commit 509682cd6a

View file

@ -19,13 +19,16 @@ module.exports = {
/** /**
* @param {Email} message - The message to send * @param {Email} message - The message to send
* @param {[EmailAddress]} recipients - the recipients to send the email to * @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<boolean>} A promise representing the success of the email sending * @returns {Promise<boolean>} A promise representing the success of the email sending
*/ */
async send(message, recipients) { async send(message, recipients, recipientData) {
for (const recipient of recipients) { for (const recipient of recipients) {
const messageToSend = Object.assign({}, message, { const messageToSend = Object.assign({}, message, {
to: recipient to: recipient
}); });
const unsubscribeUrl = recipientData[recipient].unsubscribe_url;
messageToSend.html = messageToSend.html.replace('%recipient.unsubscribe_url%', unsubscribeUrl);
try { try {
await ghostMailer.send(messageToSend); await ghostMailer.send(messageToSend);
} catch (err) { } catch (err) {