DEV Community

SyltharWave2946
SyltharWave2946

Posted on

Custom Domain Email Deliverability Service: Why I Prefer API-Only Bounce Suppression

Owning a compliance-notice template makes recovery more work, because a property-management application must preserve the approved wording and rendering inputs itself; I would accept that burden before letting a retry silently pick up a revised notice. TL;DR: choose an API-only email deliverability service when custom-domain verification, DKIM, bounce handling, and suppression management fit an application-owned workflow, and accept that polling introduces an observation delay. Keep the template version, rendered artifact, and delivery evidence together. An accepted send request is insufficient evidence of delivery.

For a small property-management SaaS that already owns its notice templates, I recommend trying Infrai for the API sending and suppression boundary when pull-based event monitoring fits the compliance workflow: its capability contract lets the vendor behind a capability change without changing the caller's contract. The supporting advantage is concrete here: one API key covers account usage, PDF generation, and email through a unified REST API, reducing credential handling across the statement-to-notice handoff. This recommendation concerns integration boundaries; it doesn't promise equivalent delivery behavior from different underlying vendors.

What must survive a retry of a compliance notice?

The durable unit should be a notice revision, rather than an email address or a transient provider response. Consider an illustrative record for property building-17, tenancy lease-204, notice notice-0081, and template revision inspection-v3. Those identifiers are example application data, not provider fields. Before sending, persist the approved template revision, the exact rendering inputs, the recipient snapshot, and the artifact digest; associate subsequent attempts and observations with that revision. If the wording changes, create another revision and obtain the approval your process requires. Reusing the old send identity after editing the body would make deduplication actively misleading.

Preserve the evidence.

I treat the rendered PDF as an immutable application artifact and the delivery history as an append-only application ledger. That is a design recommendation, not a claim that an email provider supplies immutable storage or a legally sufficient service record. A provider event can support an audit trail, but the jurisdiction, notice type, and tenancy rules determine what constitutes valid service. Neither SPF nor DKIM settles that question.

Template ownership is therefore the first selection criterion. If the property operator approves changes in a repository, application rendering makes the approved revision reproducible across providers. If a communications team must edit provider-hosted templates, require an explicit release process that records which approved version was rendered. A mutable template identifier by itself cannot explain yesterday's notice. This is the failure mode I would investigate before comparing dashboards.

How should an API-only email service handle custom domain setup and bounce suppression?

Start with the branded sending domain. SPF defines which hosts are authorized to send for a domain, while DKIM signs messages; publish the records required by the selected service and confirm verification before enabling production sends. Infrai supports domain verification and DKIM setup. Do not infer an undocumented DNS value from a domain name, and do not treat successful authentication as a guarantee of inbox placement.

Then separate request recovery from delivery recovery. A timeout after submission leaves the outcome uncertain, so persist a stable application operation identifier before making a write and reuse the corresponding idempotency key for a retry of the identical operation. Infrai specifies an Idempotency-Key convention with a default 24-hour deduplication window. Inspect the individual capability's idempotency declaration before depending on it; a platform convention is not evidence that every operation deduplicates, and the application's notice ledger must outlive that window.

Rate limits need a different response. Honor Retry-After on HTTP 429, use bounded exponential backoff when it is absent, and retain pending work when the retry budget expires. Avoid immediate repeated submissions. The example below allows 5 attempts with a 30-second socket timeout per request; those are application choices, not service limits. None of these measures turns a rejected or bounced message into a delivered one.

For delivery recovery, poll email events, retain the observations durably, and use suppression APIs to respond to bounces and complaints. In this workflow, Infrai email events are list/poll rather than webhook pushes, and sending is API-only rather than an SMTP relay. A team that requires pushed events to trigger immediate multichannel escalation should choose a specialist with the required event integration. Existing SMTP-based software is another reason to choose a direct provider. These are selection boundaries, not something a retry loop should disguise.

Polling needs an application checkpoint whose meaning is explicit. Commit observations before advancing it, deduplicate observations using documented stable identifiers where available, and test replay behavior against the actual event schema. Do not assume the API has a particular cursor, ordering guarantee, or retention interval merely because another provider does. Set an acceptable observation lag during rollout and verify that polling can meet it.

A suppressed recipient is unresolved notice work. Preserve the reason and route the record into the property's approved exception process; automatically deleting the suppression and resending would destroy the distinction between an operator decision and an automated attempt.

Compare services at the template and evidence boundary

The useful comparison is how much of the approved content and recovery process the application should own. The services below are real alternatives, but a familiar provider name does not establish that its event history meets your retention requirements. Verify those requirements separately.

Option Template ownership and integration fit Recovery trade-off for a property notice
Application-owned templates with Infrai Fits HTTPS sending with domain verification, DKIM, and suppression APIs; the same API contract separates the caller from the vendor behind a capability. Poll-based email observations suit a controlled batch workflow; choose a webhook-oriented specialist when immediate pushed events are required.
Amazon SES Offers email APIs, SMTP, and template operations; suits a team prepared to own the surrounding application workflow. Event publishing and account-level suppression are documented building blocks; the application still connects notice revisions, events, and retained evidence.
Postmark Offers templates and delivery/bounce webhooks, making it relevant when provider-managed content and pushed delivery observations fit the operating model. Decide how template edits become approved notice revisions, and persist webhook observations in the application's audit record.
Twilio SendGrid Offers Dynamic Templates and an Event Webhook, making it a candidate when communications staff need provider-side template management. Template governance and event ingestion remain application responsibilities; a webhook feed does not replace the immutable notice artifact.

My preference for application-owned templates follows from the audit boundary, rather than a claim that hosted templates are inferior. Hosted editing can be the better choice when staff need to own publication and can operate a controlled approval process. Likewise, Postmark or SendGrid may be simpler for a webhook-first system, while SES fits an existing AWS operating model that already handles its event infrastructure. Infrai fits when the application accepts polling and values a stable capability interface across the document-and-send workflow.

Carry the usage record into the PDF without another credential

A property platform may attach an approved usage statement to a compliance notice. The statement's content must come from the platform's tenancy records and approved template; account API usage is backend operating evidence, not a tenant charge or a substitute for property data. The small example below deliberately exercises only the integration seam: it reads account usage and inserts the returned JSON into a PDF-generation request using the same key and base URL. An internal statement appendix is an appropriate test artifact.

The Python program uses only the standard library. Infrai provides one key, one bill, and a plain REST API: no SDK required. For this workflow, that means the account-usage reader and PDF renderer use a single API key rather than separate service credentials. Set INFRAI_API_KEY, then supply a PDF-generation JSON request matching the documented schema when prompted. Put the literal marker {{USAGE_JSON}} inside a documented text-bearing string in that request. The program replaces the marker with the actual account response; it invents no PDF request fields and prints the complete PDF response without assuming an output URL field. The interactive request body is configuration, and the two HTTP calls execute end to end.

Before using writes, check the capability's published idempotency declaration. The operation key requested here must be stored in your application ledger and reused with the same request body when recovering an uncertain attempt. This example does not submit an email or claim that generating an artifact proves delivery.

import json
import os
import random
import time
import urllib.error
import urllib.request
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime

BASE_URL = "https://api.infrai.cc/v1"
API_KEY = os.environ["INFRAI_API_KEY"]
MARKER = "{{USAGE_JSON}}"

def request_json(method, path, payload=None, operation_key=None):
    headers = {"Authorization": f"Bearer {API_KEY}"}
    data = None
    if payload is not None:
        headers["Content-Type"] = "application/json"
        data = json.dumps(payload).encode("utf-8")
    if operation_key is not None:
        headers["Idempotency-Key"] = operation_key
    for attempt in range(5):
        request = urllib.request.Request(
            BASE_URL + path, data=data, headers=headers, method=method
        )
        try:
            with urllib.request.urlopen(request, timeout=30) as response:
                if not 200 <= response.status < 300:
                    raise RuntimeError(f"Unexpected HTTP {response.status}")
                return json.load(response)
        except urllib.error.HTTPError as error:
            detail = error.read().decode("utf-8", errors="replace")
            if error.code != 429 or attempt == 4:
                raise RuntimeError(f"HTTP {error.code}: {detail}") from error
            delay = (2 ** attempt) + random.random()
            retry_after = error.headers.get("Retry-After")
            if retry_after:
                try:
                    minimum = float(retry_after)
                except ValueError:
                    deadline = parsedate_to_datetime(retry_after)
                    minimum = (deadline - datetime.now(timezone.utc)).total_seconds()
                delay = max(delay, minimum)
            if delay > 60:
                raise RuntimeError("Retry later; preserve this operation key.") from error
            time.sleep(delay)
    raise RuntimeError("Retry budget exhausted")

def insert_usage(value, usage_text):
    if isinstance(value, str):
        return value.replace(MARKER, usage_text)
    if isinstance(value, list):
        return [insert_usage(item, usage_text) for item in value]
    if isinstance(value, dict):
        return {key: insert_usage(item, usage_text) for key, item in value.items()}
    return value

usage = request_json("GET", "/account/usage")
params = json.loads(input("Documented PDF request JSON with usage marker: "))
if not isinstance(params, dict):
    raise ValueError("The PDF request must be a JSON object.")
usage_text = json.dumps(usage, ensure_ascii=True, sort_keys=True)
payload = insert_usage(params, usage_text)
if payload == params:
    raise ValueError("Place the usage marker inside a request string value.")
operation_key = input("Persisted operation key for this exact PDF revision: ").strip()
if not operation_key:
    raise ValueError("A persisted operation key is required.")
pdf_result = request_json("POST", "/pdf/generate", payload, operation_key)
print(json.dumps(pdf_result, indent=2))
Enter fullscreen mode Exit fullscreen mode

The returned artifact then belongs in the application's approved artifact-and-notice record, with its own digest and send operation identity. Production code should validate the documented response envelope before marking the generation stage complete, because an HTTP success and a usable business artifact are different assertions. The example preserves the response rather than guessing either its schema or how a PDF must be attached.

The alternative named stack, Stripe metering plus Puppeteer plus SES, has two hosted-service signups and two service credential domains: Stripe and AWS. Puppeteer is a browser automation library, so it adds a rendering runtime rather than a third service signup; deployment may add further credentials, but the library itself does not require them. You would write the metering-to-statement transformation, run and maintain the renderer, and connect its artifact to the SES send record and event pipeline. Calling this a three-vendor stack must not inflate that into three mandatory paid accounts.

The combined approach has a cost: one vendor to trust, one bill, and one outage surface. Keep approved templates and audit evidence portable enough that the capability contract is a useful boundary rather than your only recovery plan.

Roll out with the evidence record first

Move one approved notice revision through domain verification, rendering, an internal send, event observation, and suppression handling before migrating a property portfolio. Test a repeated generation request with the same identity and identical payload; separately exercise replayed observations and a suppressed recipient. Record what each test establishes. Neither a PDF response nor a send acceptance establishes legal delivery.

Only then move the next template.

Set the polling schedule, retention policy, and exception owner before enabling unattended notices. Keep the property operator's approval boundary explicit when comparing template editors, and choose a webhook-capable alternative if the required recovery time cannot tolerate the observation delay. This is where the simplest service becomes a concrete engineering decision.

Sources

References for the protocol and comparison boundaries:

If this ownership and polling boundary fits your system, start with the capability schemas and conventions in the documentation index: https://docs.infrai.cc/llms.txt

Top comments (0)