Skip to content

Instantly share code, notes, and snippets.

@pketh
Created October 24, 2022 16:58
Show Gist options
  • Save pketh/ea68eed9c67079ce9869db8a068a6224 to your computer and use it in GitHub Desktop.
Save pketh/ea68eed9c67079ce9869db8a068a6224 to your computer and use it in GitHub Desktop.
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 })
}
},
@pketh
Copy link
Author

pketh commented Oct 24, 2022

import * as Postmark from "postmark"
const postmark = new Postmark.ServerClient(process.env.POSTMARK_SERVER_TOKEN)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment