import { ServerClient } from 'postmark' import { POSTMARK_SENDER_ADDRESS, POSTMARK_API_KEY, MAILSHIP_NAME, BASE_URL } from './env.js' import type { Subscription } from './alert.js' import { render } from './templates.js' const client = new ServerClient(POSTMARK_API_KEY) export const sendConfirm = (sub: Subscription) => { const href = `${BASE_URL}/confirm?token=${sub.key}` return client.sendEmail({ From: POSTMARK_SENDER_ADDRESS, To: sub.email, Subject: 'Confirm your email digest', HtmlBody: `
Please confirm that you would like to receive ${sub.frequency} digests by clicking the link below:
`, TextBody: `Please confirm that you would like to receive ${sub.frequency} digests by visiting: ${href}`, }) } export const sendDigest = async (sub: Subscription, variables: Record