A mail provider accepting an API request records an attempt, not guaranteed inbox delivery. Later events may report delivery, delay, rejection, bounce, or complaint, and they can arrive more than once or out of order. The application must map provider message IDs back to its own intent and recipient, validate event authenticity under the chosen provider contract, and update state monotonically. A hard failure or complaint may suppress further optional mail to that address. Temporary failures require a bounded retry policy, while a security-critical notice may need another approved channel if email cannot arrive. Suppression policy depends on message purpose; promotional and transactional notices should not be collapsed into one toggle.
Email Provider Events, Bounces, and Suppression
Working case
Case notice intent 62 was accepted by a provider but later reports a permanent bounce for reviewer 29’s address. The event handler verifies the callback, finds the matching provider ID, marks the attempt bounced, and records a suppression reason for the address under the appropriate category. A duplicate bounce event does not change counts twice. A delayed delivered event for an older attempt cannot erase the newer bounce. The case assignment itself remains. The app can show a neutral in-product notice asking reviewer 29 to update contact information rather than repeatedly sending to an unusable mailbox.
Implementation boundary
function maySendNotice(suppression, purpose) {
return !suppression.has(purpose);
}
console.log(maySendNotice(new Set(["optional"]), "optional"));
// Output: falseStore the application intent ID and provider message ID mapping per recipient; multi-recipient sends complicate feedback attribution, so choose batching carefully. Validate signed provider callbacks and event IDs, then deduplicate before applying transitions. Separate accepted, delayed, delivered, bounced, complained, and unknown states with timestamps and provider references. Classify permanent and transient failures according to current provider definitions, not a string fragment. Maintain suppression at the appropriate account or tenant scope, and check it before every optional send. Define how account-security messages behave when an address is suppressed, including safe alternate routes. Reconcile missing feedback on a schedule without claiming silence means delivery.
Cost and boundaries
An event callback uses indexed message lookup and O(1) state update in the common case. Each attempt and feedback item adds small storage, while repeated transient retries can grow provider cost and reputation risk. A suppression lookup per send is cheap with an index; stale suppression data can keep sending to invalid addresses. Collect aggregate bounce, complaint, delay, and provider rejection rates without logging full addresses or message bodies. Monitor feedback lag, unknown provider IDs, duplicate events, suppression effectiveness, and critical notices with no working channel.
Failure trace
The app treats API accepted as delivered and tells a user the recipient read the notice. A later bounce arrives, but the UI has no state for it. Keep accepted distinct from delivered and never infer human reading from delivery. Another worker retries a permanent bounce indefinitely, harming sender reputation and flooding logs. Suppress or stop according to policy. Test forged callback, duplicate event, delayed earlier event, missing provider ID, changed recipient address, provider outage, temporary rejection, and a complaint that must halt optional messages without hiding a required account notice.
Verification
- Provider acceptance and recipient delivery have distinct states.
- Duplicate feedback cannot overwrite a later terminal event.
- Suppression is checked by purpose before sending.
Practice drill
Send one notice for reviewer 29 and persist its provider ID. Deliver accepted, delayed, bounce, and duplicate bounce events in a test runner. Verify a valid signature is required and a stale delivered event cannot override the bounce. Attempt another optional notice and confirm suppression blocks it. Change the address through an authenticated account flow, then verify the new address has its own confirmation and send policy. Measure unresolved attempts and check that the dashboard does not label provider acceptance as mailbox reading.
Decision note
Treat provider feedback as asynchronous evidence, deduplicate it, and enforce purpose-aware suppression before new sends.
Common Mistakes
- Equating provider acceptance with user reading.
- Retrying permanent bounces as transient failures.
- Applying one preference to every security and optional message.
Connected lessons
Outbound Email and Delivery State; Email Intent, Outbox, and Idempotent Send; Email Template Data and Account Link Boundaries; Sender Identity, Reputation, and Message Observability; Signed Webhook Delivery and Replay Control; Email Intent, Outbox, and Idempotent Send; Notification Opt-In and Channel Preference.
Apply and check
Build Project: account email delivery and review Web Development: file and email delivery decisions quiz.
