← Dashboard
Section 11 of 14

Email Notifications

What This Does

The app sends 8 types of email notifications via Resend (an email API service). Error alerts, review needed, plan limit warnings, ShipStation disconnect reminders, price discrepancy alerts, daily/weekly review digests, and split shipment notices. Each has an HTML template for visual emails and a plain text fallback.

Why It Matters

Merchants need to know what's happening with their orders without logging into the app constantly. Error emails help them fix issues fast. Review emails prompt them to approve corrections. Plan limit warnings prevent unexpected processing stops.

How It Works

  1. 1.The sendOrderAlert() function is the single entry point — you pass it an alert type and context data.
  2. 2.Each alert type has its own template function that generates subject, HTML, and plain text.
  3. 3.All templates use a shared baseLayout() for consistent email branding (Declared header, unsubscribe footer).
  4. 4.All user-provided data is escaped with escapeHtml() to prevent XSS in email clients.
  5. 5.Email delivery uses Resend's API — we pass the HTML, subject, and recipient, and Resend handles SMTP delivery.
  6. 6.Notification preferences on the Shop model control which emails are sent (notifyOnError, notifyOnPlanLimit, reviewNotifyFrequency, etc.).

The Code

Key Decisions

What Could Go Wrong