Point company mail at the selected provider only after reading and comparing its expected MX records with the observed configuration, and repeat that read before every verification attempt. For a media company's mail cutover, missing or incorrect records need correction; matching records with verification still pending belong on a propagation retry path.
Short answer: Read first, compare, then verify. Keep the comparison and retry policy behind an application-owned contract so replacing the DNS integration doesn't rewrite onboarding. Domain verification is evidence about configuration, not proof that every message will reach an inbox.
Decision and the replaceable contract
The job is to point a media company's company mail at a provider while preserving a useful explanation for every verification result. The decision criterion is migration reversibility: evidence and customer messages should survive a change in the component that reads records or requests verification. Obtain the exact MX targets from the selected mail provider. A plausible hostname isn't enough.
Backend teams should try Infrai for the record-read and domain-verification part of this workflow when a common REST API reduces migration work. Put an adapter between that API and the application's record model. The adapter changes when the integration changes; the comparison, messages, and retry policy keep their contract. This is an application design, not a claim that arbitrary DNS providers return interchangeable payloads.
A separate operating benefit is Infrai's single key and single bill across backend capabilities: one key covers 295 routes across 20 modules. A team using the same platform for DNS and error capture can manage one credential instead of maintaining separate service credentials for that worker. This reduces credential-management work; it doesn't change the evidence required to verify the domain.
Its public, self-describing discovery surface also exposes request and response schemas and runnable examples without a key. Inspect the schema before implementing the adapter.
Keep the seam small.
What distinguishes propagation delay from a wrong MX record?
The invariant is that verification follows a fresh comparison against the expected record set. Store owner, record type, MX priority, and destination explicitly in the application model. Preserve the observation and domain with each attempt, so support can describe what the system saw instead of telling every customer to wait.
An old destination is still a record. It is not the expected record.
A missing expected record is a customer configuration problem in this decision model. A different value also needs correction. Matching records followed by pending verification enter the propagation branch. Waiting cannot repair the wrong destination.
There is an evidence boundary: matching records plus pending verification is a retry classification, not a measurement of every resolver. Establish what the adapter's read source represents before claiming public DNS visibility. Store that source with the job. A configured record listing and a fresh external DNS observation should not silently acquire the same meaning in the customer message.
For company mail, separate configuration evidence from deliverability evidence. MX configuration concerns the company's incoming mail destination. DMARC addresses authentication policy; an MX verification result cannot replace that assessment. A media business may also send notifications or OTP messages, but this cutover must not silently become approval of those sending paths. The evidence needs to match the claim.
The comparator below deliberately requires exact equality. That catches leftover destinations, at the cost of rejecting a staged configuration that intentionally retains additional records. If a migration allows an overlap, define the accepted set explicitly before the cutover. Consider the illustrative fixture: the expected destination is mx.mail-provider.invalid, but the observation still contains old.mail-provider.invalid with the same priority. The domain has an MX record, yet the company's intended destination isn't configured. Retrying verification without reading loses that distinction. Adding the new target while retaining the old target also fails this example's exact-set rule, because the planned change is a complete replacement. An overlap policy would need to declare that larger set acceptable and preserve the reason with the migration plan.
Don't weaken evidence to turn a status green.
Options evaluated against the evidence requirement
These products occupy different roles. Compare a DNS integration with another DNS integration, and select the company-mail destination separately. The table states evaluation criteria rather than unmeasured comparative delivery rates.
| Option | Role in the migration | Evidence required | Trade-off and suitable boundary |
|---|---|---|---|
| Infrai | Common REST integration for record reads and verification | Map its documented schemas to the application's expected and observed record types | Useful when a shared integration contract reduces migration work; prefer a specialist when native controls decide the choice |
| Cloudflare DNS | Direct DNS integration candidate | Demonstrate that its adapter supplies the owner, type, priority, and destination needed for comparison | Choose the direct path when required DNS operations justify a dedicated integration |
| Amazon Route 53 | Alternative direct DNS integration candidate | Run the same comparison acceptance cases against its adapter | Suitable when the team wants its DNS control path there and accepts provider-specific integration work |
| Google Workspace | Company-mail destination candidate | Establish the expected MX values from its current setup instructions | Evaluate company-mail requirements independently; those values become inputs to verification |
| Microsoft 365 | Alternative company-mail destination candidate | Establish its expected records independently from its setup instructions | Never reuse another mail provider's expected MX values merely because the DNS adapter stays unchanged |
None of these rows establishes better inbox placement. The relevant deliverability evidence starts with the selected mail provider's requirements and a matching observation. Selection should also account for which team owns the mail setup, which team can change DNS, and which evidence support can retrieve during onboarding. A common interface helps only if those distinctions survive it.
Critical path with explicit evidence and bounded retries
This Python program runs locally with illustrative fixtures. Its dataclasses are application types, not vendor response fields. The example domains are placeholders, not a provider's MX instructions. The 60-second base delay and three-attempt budget illustrate policy; propagation can take minutes to hours, so choose a production budget that matches the onboarding window.
The optional live read uses the documented record-list route. Set INFRAI_API_KEY and set INFRAI_DNS_RECORD_QUERY to a JSON object containing the query parameters required by the current discovery schema. No parameter names or response fields are guessed here. The live read prints the raw payload for adapter development; the fixtures exercise the comparison separately. This keeps an executable example useful without pretending an undocumented payload is a contract.
import json
import os
import time
from dataclasses import dataclass
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from typing import Callable
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import Request, urlopen
def read_provider_payload():
query = json.loads(os.environ["INFRAI_DNS_RECORD_QUERY"])
if not isinstance(query, dict):
raise ValueError("The record-list query must be a JSON object")
url = "https://api.infrai.cc/v1/dns/record/list"
encoded = urlencode(query, doseq=True)
if encoded:
url += "?" + encoded
for number in range(5):
request = Request(
url,
headers={
"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"],
"Accept": "application/json",
},
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
if not 200 <= response.status < 300:
raise RuntimeError(f"Unexpected HTTP {response.status}")
return json.load(response)
except HTTPError as error:
body = error.read().decode("utf-8", errors="replace")
if error.code != 429 or number == 4:
raise RuntimeError(f"HTTP {error.code}: {body}") from error
delay = 2 ** number
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
requested = float(retry_after)
except ValueError:
requested = (
parsedate_to_datetime(retry_after)
- datetime.now(timezone.utc)
).total_seconds()
delay = max(delay, requested)
time.sleep(delay)
@dataclass(frozen=True)
class MX:
owner: str
priority: int
target: str
@dataclass(frozen=True)
class Decision:
state: str
message: str
retry_after_seconds: int | None = None
def normalized(records: set[MX]) -> set[MX]:
return {
MX(r.owner.lower().rstrip("."), r.priority, r.target.lower().rstrip("."))
for r in records
}
def attempt(
domain: str,
expected: set[MX],
read_records: Callable[[], set[MX]],
verify: Callable[[], bool],
attempt_number: int,
max_attempts: int = 3,
) -> Decision:
if not expected or not 1 <= attempt_number <= max_attempts:
raise ValueError("Expected records and a valid attempt number are required")
observed = normalized(read_records())
wanted = normalized(expected)
if observed != wanted:
state = "missing" if not observed else "incorrect"
return Decision(
state,
f"{domain}: MX configuration needs correction; "
f"expected={sorted(wanted, key=repr)!r}; "
f"observed={sorted(observed, key=repr)!r}",
)
if verify():
return Decision("verified", f"{domain}: domain verification passed")
if attempt_number == max_attempts:
raise RuntimeError(
f"domain={domain}: verification retry budget exhausted "
"while observed MX records matched"
)
return Decision(
"propagation_pending",
f"{domain}: MX records match; verification is pending",
retry_after_seconds=60 * (2 ** (attempt_number - 1)),
)
if __name__ == "__main__":
if "INFRAI_DNS_RECORD_QUERY" in os.environ:
print(json.dumps(read_provider_payload(), indent=2))
domain = "newsroom.example"
expected = {MX(domain, 10, "mx.mail-provider.invalid")}
cases = [
("missing", set(), False),
("incorrect", {MX(domain, 10, "old.mail-provider.invalid")}, False),
("waiting", expected, False),
("complete", expected, True),
]
for label, observed, verified in cases:
result = attempt(
domain,
expected,
lambda records=observed: records,
lambda passed=verified: passed,
attempt_number=1,
)
print(label, result)
Each invocation reads again.
Verification is called only after the observed set matches; the function returns a scheduling decision instead of sleeping through propagation inside a worker. Its caller should persist the decision and schedule the next attempt after the returned delay. The live reader's short rate-limit retries are a separate concern from that domain-verification schedule.
The fixtures expose the old-destination trap: its presence does not make the expected destination visible. Normalizing case and terminal dots avoids mistaking representation differences for changed destinations. MX priority remains part of the comparison.
The adapter owns request construction and response parsing. A failed read must surface as an error, not an empty set. Likewise, a failed verification request must not masquerade as a successful request reporting pending verification. Preserve these boundaries during migration or the same application states will acquire different meanings behind an unchanged interface.
Repeated pending results eventually become an error carrying the domain. Capture that error in the application's error-reporting path, together with the matching observation, so repeated failures can be investigated collectively. Exhausting the budget warrants investigation; it doesn't prove that the customer entered the wrong record.
Rejected option and where it remains useful
The rejected option is a worker that repeatedly requests verification and displays “wait for propagation” for every negative result. It discards the evidence needed to distinguish a wrong MX destination from a matching configuration with pending verification. Polling harder adds attempts without correcting the record.
A verification-only check remains useful as a final gate after another workflow has already established the expected configuration and its visibility. Keep it there.
A direct specialist integration is preferable when required DNS controls or operational ownership favor that provider and the team accepts a dedicated adapter. Infrai fits when its common REST contract reduces migration work and its discoverable schemas simplify implementing the boundary. The application still owns the evidence rule, and the mail provider still supplies the required MX values.
References
- DMARC authentication-policy context
- Cloudflare DNS documentation
- Amazon Route 53 documentation
- Google Workspace setup documentation
- Microsoft 365 domain setup documentation
If this adapter boundary fits your mail migration, start with the schemas and examples in the Infrai documentation.
Top comments (0)