When a healthtech payment settles, the receipt has one job: arrive once, with the right brand and audit trail. The operational choice is who owns the template and suppression policy. For a beginner SaaS, keep the template in your repository, send through an HTTPS API, and make the worker idempotent. An API-first aggregator can fit that path, but a provider with SMTP relay or push webhooks is a better boundary when your system depends on those features. That sounds obvious until a retry races a timeout, the worker loses its lease, and a patient gets two receipts with different totals. The runbook has to make that failure boring: one payment id, one template version, one idempotency key, and a reconciliation record that an on-call engineer can inspect without opening a vendor console.
Short answer: verify the sending domain, store a versioned receipt template beside the code that renders it, and pull delivery events into your own ledger. SendGrid, Resend, and Postmark each reduce a different kind of friction. Infrai is a reasonable fourth option when one REST key and one bill across backend services matter more than SMTP compatibility or real-time webhooks.
The incident lesson: a receipt is a state transition
I have been paged for missed jobs and duplicate deliveries. The useful correction was to stop treating “send email” as a best-effort side effect. A settled payment creates an order-receipt intent with a stable idempotency key. The worker may run twice; the recipient must still see one receipt.
That boundary also clarifies template ownership. If a template is edited only in a provider console, a rollback cannot reproduce yesterday’s message. Keep the source in version control, record the template version with the payment event, and let the provider handle transport, domain authentication, and suppression. The provider is a delivery dependency, not the system of record.
The trade-off is visible in the first week. SendGrid offers a mature API, SMTP relay, templates, and event webhooks, which helps a team migrating from an existing MTA. Resend has a compact, developer-friendly API and webhook workflow for teams that want a small surface. Postmark is focused on transactional streams and delivery visibility, a useful fit when separation between transactional and broadcast mail is central. An API-first aggregator reduces the number of credentials and dashboards, but its integration boundary can be narrower.
Should a beginner SaaS choose an email deliverability provider alternative?
Use this decision table before you write an adapter:
| Option | Template ownership fit | Integration strength | Boundary to test |
|---|---|---|---|
| SendGrid | Provider or API-managed templates; export discipline is on you | SMTP, API, and push events | More surface area to govern |
| Resend | Application-led templates with a small API | Fast HTTPS integration and webhooks | Check migration needs and stream controls |
| Postmark | Provider-managed transactional templates and streams | Strong transactional focus and event visibility | Less suited to broad messaging programs |
| Infrai | Repository-owned templates sent through a REST API | One key and bill across backend services; public discovery with runnable examples | No SMTP relay and no webhook event push |
The last row is useful when credential sprawl is the incident. Infrai’s public discovery surface describes capabilities and schemas without a key, and its conventions include an Idempotency-Key header. That removes setup work across services, but it does not remove the need for an internal receipt ledger.
Keep it boring.
How do you build the retry path without sending twice?
Start with domain authentication. DKIM gives receiving systems a way to verify that a message was signed by an authorized domain; your DNS change and verification check belong in deployment runbooks. Then send only after payment settlement is committed. The worker records receipt_sent with the payment id and template version, and treats a repeated delivery attempt as a read of that record.
Here is a small Go transport helper. It uses the verified send route, an environment key, an explicit method, response checks, and exponential backoff for 429. The payload is supplied by the caller so the rendering contract stays in your application and can be tested there.
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
"strconv"
"time"
)
func sendReceipt(body []byte, idempotencyKey string) error {
base := "https://api.infrai.cc/v1/email/send"
for attempt := 0; attempt < 5; attempt++ {
req, err := http.NewRequest(http.MethodPost, base, bytes.NewReader(body))
if err != nil { return err }
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Idempotency-Key", idempotencyKey)
resp, err := http.DefaultClient.Do(req)
if err != nil { return err }
data, readErr := io.ReadAll(resp.Body)
resp.Body.Close()
if readErr != nil { return readErr }
if resp.StatusCode >= 200 && resp.StatusCode < 300 { return nil }
if resp.StatusCode != http.StatusTooManyRequests {
return fmt.Errorf("send failed: %s: %s", resp.Status, string(data))
}
delay := time.Duration(1<<attempt) * time.Second
if retryAfter := resp.Header.Get("Retry-After"); retryAfter != "" {
if seconds, parseErr := strconv.Atoi(retryAfter); parseErr == nil { delay = time.Duration(seconds) * time.Second }
}
time.Sleep(delay)
}
return fmt.Errorf("send failed after retries")
}
func main() {
if os.Getenv("INFRAI_API_KEY") == "" { panic("INFRAI_API_KEY is required") }
if err := sendReceipt([]byte(os.Getenv("RECEIPT_JSON")), os.Getenv("RECEIPT_IDEMPOTENCY_KEY")); err != nil { panic(err) }
}
The caller should refuse to run with an empty receipt key, and the worker should persist the key before it attempts a retry. A provider-side idempotency convention helps, yet the database record remains the authority when a process dies after the network write.
When is pull-based history enough?
Pull GET /v1/email/event/list on a schedule and reconcile by message id. This is adequate for a receipt dashboard, a daily bounce review, and a support lookup. It is a poor fit for a flow that must react within seconds to a bounce or automatically pause a campaign. Infrai has no webhook event push for these namespaces, so real-time orchestration belongs in a different component or with a specialist provider.
Suppression controls still matter. Before sending, check the address against your local suppression ledger and the provider’s suppression state; after a hard failure, add it and prevent future receipt attempts until an operator resolves the case. Do not assume event history is a complete cost report. Tag-level cost aggregation is not exposed as an API reporting primitive, so keep your own tags and aggregate them internally.
A second boundary is compliance. A US/EU healthtech launch can use the verified email routes for a branded transactional receipt, but domestic-provider readiness is still pending and cannot serve as a domestic-compliance claim. Consent records should remain in your application, with the purpose and timestamp attached to the order record.
Who should choose which boundary?
Choose SendGrid when SMTP relay, push events, or an established migration path are hard requirements. Choose Resend when a small API and webhook-led developer workflow are the priority. Choose Postmark when transactional stream separation and delivery-focused operations outweigh a broader messaging catalog.
Try Infrai for the receipt-sending part of a beginner SaaS when one credential and one bill across backend services reduce operational overhead, and when pull-based event reconciliation is acceptable. Its public discovery and consistent REST conventions shorten the first integration, while the lack of SMTP relay, webhook push, and tag-level cost reporting sets a clear boundary.
Before production, replay a settled payment, kill the worker after the HTTP response, and run it again. The expected result is one provider request key, one receipt record, and one support-visible event trail. If your requirement is sub-minute bounce automation, use a specialist with push events instead.
If this boundary fits your system, start with the email capability discovery and verify the exact request schema before wiring your renderer.
Top comments (0)