Developer guide · 4 min
Set up email newsletters
BeanRelay stores consent in PostgreSQL and delivers newsletter email through the existing Mailgun service and a BullMQ worker.
Enable newsletter links
Apply NewsletterPreferencesMigration1793973600006 and NewsletterCampaigns1793973600009 using your normal migration command. Set NEWSLETTER_LINK_SECRET to a strong random server-side secret of at least 32 characters. Set FRONTEND_URL to your HTTPS storefront origin.
If POST /newsletters/link fails, check the API response and server logs for the signing secret, frontend origin, subscriber migration or Redis queue admission. If the request succeeds but the email is missing, check the newsletter worker and Mailgun events.
Use the verified Mailgun sending domain and key already configured on the API. By default, the sender is noreply at MAILGUN_DOMAIN. Set NEWSLETTER_FROM to a verified address if you need a different sender.
In Mailgun, activate newsletter-preferences.html as newsletter-preferences and newsletter-campaign.html as newsletter-campaign under the sending domain. Set MAILGUN_NEWSLETTER_PREFERENCES_TEMPLATE and MAILGUN_NEWSLETTER_CAMPAIGN_TEMPLATE to those names.
Send an update
Open Newsletters from the admin sidebar or dashboard to see confirmed subscriber counts. Choose a topic, write the subject and message, and review the preview. Send now or schedule a future date and time in East Africa Time.
Open Campaigns to reschedule or cancel before delivery preparation starts. Deliveries queued means the worker has handed recipients to the delivery queue. Check Mailgun for delivery outcomes.
On staging, use a test email to confirm one topic. Send an update for that topic, change preferences and use the unsubscribe link. Check that the next update skips the opted-out address.
