Created
October 24, 2022 16:58
-
-
Save pketh/ea68eed9c67079ce9869db8a068a6224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async bulletin ({subject, users, exploreSpaces}) { | |
const batches = utils.groupIntoBatches(users) | |
console.log('📧 bulletin', { subject, users: users.length, batches: batches.length }) | |
for (const users of batches) { | |
const templates = users.map(user => { | |
return { | |
From: "[email protected]", | |
To: user.email, | |
TemplateAlias: "bulletin", | |
MessageStream: "bulletins", | |
TemplateModel: { | |
subject, | |
newExploreSpaces: exploreSpaces, | |
host: utils.host(), | |
unsubscribeUrl: `${utils.apiHost()}/user/unsubscribe-email-bulletins?userId=${user.id}`, | |
}, | |
} | |
}) | |
await postmark.sendEmailBatchWithTemplates(templates) | |
console.log('☕️ bulletin: emailed batch', { emails: templates.length }) | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import * as Postmark from "postmark"
const postmark = new Postmark.ServerClient(process.env.POSTMARK_SERVER_TOKEN)