This page covers how Newsletter content is published via email. That content is also manually cross-published like blog posts to the https://www.peels.app/newsletter page. See Markdown Pages for more information on that.
Email newsletters mirror (and are done after) their Markdown Pages counterparts. In other words:
Email newsletter issue content lives in supabase/functions/templates. The content is textually the same as the web version but formatted for email, so uses different components.
For example: newsletter-issue-one-email contains the contents of Issue 1: Celebrating the First Few Months of Peels and visually matches its https://www.peels.app/newsletter/celebrating-the-first-few-months web counterpart but the markup is different.
Email are sent in two parts, to our two respective newsletter audience (subscriber) types:
send-email-for-newsletter-issue-supabase-userssend-email-for-newsletter-issue-resend-audienceStart with the supabase-users edge function first. It’s more malleable and allows for testing. The resend-audience edge function is done in one hit, and therefore dangerous.
<aside> 👉
Use the testEmail functionality in the supabase-users edge function to test this email to yourself before sending it out to anyone. There are bound to be tweaks that need to be made.
</aside>
Note that the supabase-users edge function looks for a emailed_latest_issue column. This should be deleted after an issue is sent out. That way we re-add it for next time.
Rewrite the above to be as clear as this:
subject hardcodes the subjectimport { NewsletterIssueOneEmail } from "../_templates/newsletter-issue-one-email.tsx";react: NewsletterIssueOneEmail({...