DEV Community

MitchellCross2134
MitchellCross2134

Posted on

Startup Email Deliverability Stack: 4 Recovery Drills for Suppression and Complaint Polling

A restarted event worker must not forget a seller's complaint. TL;DR: choose a startup transactional email deliverability stack by rehearsing recovery of suppression state before comparing sending features. Domain verification, bounce and complaint polling, and idempotent processing make a practical foundation when the team can own a small reconciliation worker. For marketplace new-order notifications, the decisive question is what survives a restart.

Consider a production-readiness exercise, not an account of an observed outage. A seller has a queued new-order notification. The event worker retrieves a complaint, then stops between updating recipient state and recording its progress. On restart, the same observation is retrieved again. The exercise has two acceptable properties: the complaint remains effective, and applying it twice does not create a second business action. Reversing those writes can instead leave progress ahead of the state it supposedly represents.

Order matters here.

The lesson is persist the recipient decision before acknowledging the observation. A poller's successful invocation is weak evidence. A recovery drill that reconstructs the same suppression decision from durable records tells the operator considerably more. This changes the selection angle: compare the recovery work each integration leaves with the startup, rather than treating a green send response as the end of delivery engineering.

How should a startup email deliverability stack recover complaint polling state?

Keep four drills on the launch checklist. They are proposed acceptance exercises, not vendor performance measurements. Use synthetic seller addresses and order identifiers; don't manufacture complaints against real recipients to test your runbook.

  1. Stop after retrieval but before persistence. Restart the worker and establish that the observation can still reach recipient state. Review the provider's actual retrieval and retention contract before choosing how progress is recorded; an assumed cursor is not a recovery mechanism.
  2. Stop after persisting suppression but before recording progress. Reprocess the observation. The recipient must remain suppressed without creating another notification or another suppression-side business action.
  3. Apply a delivery observation after a complaint. Confirm that the later processing step cannot silently restore eligibility. Delivery evidence and permission to send answer different questions.
  4. Restart the sending worker after its request outcome becomes unknown. Preserve the order notification's original business identity and reconcile acceptance before allowing another attempt. A new retry number must not become a new message identity.

The third drill is easy to overlook. A single mutable status such as “latest email event” can conflate transport history with recipient policy. Instead, preserve the observation and the policy decision separately. A record that a previous message was delivered should remain available for diagnosis without undoing a complaint block. Treat re-enablement as a separate, authorized process with its own evidence.

Don't reset suppression.

For a dedicated sending domain, complete domain verification and plan DKIM rotation before launch. Keep the verification evidence alongside the release checklist, separate from the per-recipient decision. Authentication setup does not prove that a seller remains eligible for another order alert, and it doesn't establish inbox placement. The worker should check both the current order state and recipient suppression immediately before attempting dispatch.

There is a deliberate trade-off: retaining enough processing history to explain a restart takes storage and operational attention. Dropping that history makes the implementation smaller but weakens the operator's ability to distinguish a repeated observation from a missed one. Define retention around your recovery requirements and privacy obligations; don't invent a universal number of days.

Compare the recovery contract before buying the sender

Infrai brings 295 routes across 20 modules behind one REST API and one key, so sending, suppression, and event retrieval can share an integration contract with scheduling and other backend capabilities. Its documented idempotency convention is a second useful property for this workflow: supported operations accept an Idempotency-Key, with a default 24-hour deduplication window. Check the individual operation's contract, and retain local notification history when recovery may extend beyond that window. The email event workflow uses polling, which makes a cron-triggered reconciliation worker part of the operating design.

That is a reasonable fit for a budget-minded startup sending transactional seller notices and willing to own that worker. The convenience is fewer integration conventions to maintain. It doesn't settle who investigates an event-processing backlog at night.

Three other real products deserve a fair review. The following comparison distinguishes selection priorities and the evidence to collect; it does not claim that any candidate wins an inbox-placement benchmark.

Candidate Reason to include it Recovery work to settle before committing
Amazon SES Evaluate email within an AWS-centered operating environment. Map the documented event and suppression workflow to the team's existing monitoring and recovery ownership. Count the components the team must operate.
Postmark Evaluate a focused transactional-email integration for order notices. Walk through its documented bounce handling and decide how the application's seller eligibility state is reconstructed after interruption.
Twilio SendGrid Evaluate an email integration against the marketplace's wider notification requirements. Review its event and suppression documentation, then identify where transport observations become durable application policy.

The differences that matter in this review are operational fit, transactional scope, and the boundary with the existing notification system. An AWS-centered team should weigh familiar operational ownership heavily. A team evaluating a focused transactional service should weigh the recipient-state handoff. A marketplace with an established notification integration should account for the cost and risk of replacing a recovery path it already understands. These are reasons to shortlist, not claims of unique capabilities.

Request a concrete recovery walkthrough from each candidate. “We handle bounces” leaves too much unspecified: which record survives, which operation can be retried, and which component owns the seller's next-send decision? If those answers are unclear, the purchase has not removed the work.

For US and EU recipients, add processing location, retention terms, and contractual requirements to that review. Do not infer regional compliance from a verified domain or a successful API call. No regional delivery or residency guarantee follows from this comparison.

Rehearse the state transition without sending mail

The following complete Go program retrieves email events, then models the second and third drills using synthetic data. Set INFRAI_API_KEY and INFRAI_BASE_URL to your key and the documented HTTPS API base ending in v1, then run the saved Go source file with the Go toolchain. Retrieval uses an explicit GET, checks status, and retries rate limits with exponential backoff while honoring Retry-After. It reports response size without printing recipient records.

Retrieval and the exercise are deliberately separate. The types below are application-owned exercise data, not provider response fields. A production adapter must decode and durably apply the actual event contract before advancing progress; a successful read alone never marks reconciliation complete.

package main

import (
    "fmt"
    "io"
    "net/http"
    "os"
    "strconv"
    "strings"
    "time"
)

func retrieveEvents() error {
    key := os.Getenv("INFRAI_API_KEY")
    base := strings.TrimRight(os.Getenv("INFRAI_BASE_URL"), "/")
    if key == "" || !strings.HasPrefix(base, "https://") ||
        !strings.HasSuffix(base, "/v1") {
        return fmt.Errorf("set the API key and HTTPS v1 API base")
    }
    client := &http.Client{Timeout: 20 * time.Second}
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequest(http.MethodGet, base+"/email/event/list", nil)
        if err != nil {
            return err
        }
        req.Header.Set("Authorization", "Bearer "+key)
        resp, err := client.Do(req)
        if err != nil {
            return err
        }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil {
            return readErr
        }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 {
            delay := time.Second * time.Duration(1<<attempt)
            retry := resp.Header.Get("Retry-After")
            if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
                if requested := time.Duration(seconds) * time.Second; requested > delay {
                    delay = requested
                }
            } else if date, err := http.ParseTime(retry); err == nil {
                if requested := time.Until(date); requested > delay {
                    delay = requested
                }
            }
            time.Sleep(delay)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return fmt.Errorf("event retrieval status %d: %s", resp.StatusCode, body)
        }
        fmt.Printf("retrieved %d bytes; reconciliation still required\n", len(body))
        return nil
    }
    return fmt.Errorf("event retrieval exhausted attempts")
}

type Observation struct {
    ID        string
    Recipient string
    Kind      string
}

type RecipientState struct {
    Suppressed bool
    Seen       map[string]bool
}

func apply(s *RecipientState, e Observation) error {
    if e.ID == "" || e.Recipient == "" {
        return fmt.Errorf("observation identity and recipient are required")
    }
    switch e.Kind {
    case "complaint", "hard_bounce", "delivery":
    default:
        return fmt.Errorf("unsupported exercise observation: %s", e.Kind)
    }
    if s.Seen[e.ID] {
        return nil
    }
    if e.Kind == "complaint" || e.Kind == "hard_bounce" {
        s.Suppressed = true
    }
    if s.Seen == nil {
        s.Seen = make(map[string]bool)
    }
    s.Seen[e.ID] = true
    return nil
}

func main() {
    if err := retrieveEvents(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
    states := make(map[string]*RecipientState)
    observations := []Observation{
        {"complaint-a", "seller-42@example.com", "complaint"},
        {"complaint-a", "seller-42@example.com", "complaint"},
        {"delivery-b", "seller-42@example.com", "delivery"},
    }
    for _, e := range observations {
        s := states[e.Recipient]
        if s == nil {
            s = &RecipientState{}
            states[e.Recipient] = s
        }
        if err := apply(s, e); err != nil {
            panic(err)
        }
        fmt.Printf("%s suppressed=%t observations=%d\n",
            e.ID, s.Suppressed, len(s.Seen))
    }
}
Enter fullscreen mode Exit fullscreen mode

The repeated complaint leaves one processed observation. The delivery adds a second observation while suppression remains true. Those are exercise assertions, not measured provider behavior.

The code intentionally keeps state in memory so the transition is visible. A production implementation must persist the suppression decision and processed observation identity atomically, scoped to the correct provider account and recipient. Otherwise, this program's behavior disappears on restart. Store retrieval progress only after the associated observations have been durably applied; if progress cannot share that transaction, replay must be safe. Use the actual event identity contract rather than assuming that a field with a familiar name is globally unique.

The sending side needs a different durable key. Tie it to the marketplace order, seller, and notification purpose. Retain that key across attempts and use it for supported idempotent writes. The observation key prevents repeated policy processing; the notification key prevents treating another attempt as another order notice. Neither key alone establishes exactly-once inbox delivery.

Know when this operating model is the wrong fit

Use polling when the marketplace accepts the observation delay and has an owner for reconciliation. Monitor completed application of events, backlog, and unresolved send outcomes. A cron trigger should enqueue bounded work; lengthy processing belongs in a worker. Standard queues require idempotent consumers because processing may occur more than once.

If the selection requires pushed events, SMTP relay migration, or voice, WhatsApp, and RCS alongside email, use a shortlist built around those requirements. If the seller-alert policy requires revocable scheduled dispatch, keep that requirement explicit during selection rather than assuming scheduling implies cancellation. Email verification-code fallback is another workflow to evaluate separately from new-order notifications.

The launch decision is small and testable: can the team stop each worker at the specified boundary and recover the same recipient decision without creating a new order notification? Passing those drills is evidence about the integration's recovery behavior. It is not an uptime promise. Choose the stack whose recovery responsibilities the team can actually carry.

References

The primary documentation below supports candidate review and the distinction between domain authentication and application policy. Use each product's current documentation to confirm its event contracts before implementing an adapter. The recovery exercises above are application design recommendations.

Sources

Top comments (0)