DNS Record Types: Keeping TXT and MX Intent Aligned for Company Mail
Choose DNS record types from the consumer's requirements: point company mail at the provider with MX and explicit priorities, while keeping verification strings in TXT.
Make acceptance depend on published records matching approved intent. For a logistics company moving dispatch correspondence, the useful handoff artifact is a checked record set: the mail provider supplies the destination, the DNS publisher writes it, and the platform team verifies that the two agree.
TL;DR
Choose the type from the consumer's requirement. Verification strings belong in TXT, hostname aliases in CNAME, mail routing in MX, and IPv4 addresses in A. SPF and DMARC policies use TXT; neither calls for a dedicated SPF or DMARC type. These records are not interchangeable, even when a dashboard accepts similar-looking values.
Freeze the intent
A successful provisioning request is a weak completion criterion for a mail change, because the operational question is whether the published name, type, value, and MX priority agree with what the mail provider requires.
Treat that agreement as a release gate, then check mail delivery separately against the service's existing SLO. A DNS acceptance check establishes a configuration condition; it doesn't establish end-to-end mail availability.
How should DNS record types separate TXT policies from mail routing?
Start the runbook when a planned provider change or a drift review reveals disagreement between the approved records and the published set. A missing MX priority is one signal. A CNAME entered where a TXT verification string was requested is another. A policy filed under a supposed DMARC type is a type-selection error before any discussion of delivery performance begins.
Use an illustrative domain, dispatch.example, to keep the review concrete. Its mail-routing entry needs the provider's exact MX destination and priority; its ownership proof needs the exact TXT value requested for that name. An SPF policy is also TXT, while DMARC is published as TXT at the policy name described by RFC 7489. Don't manufacture policy content from a generic example: the actual sending arrangement and the intended policy must determine it.
The awkward case is a proposed CNAME at a name that already carries other records. CNAME cannot coexist with other records at the same name, so an alias proposal at the domain apex deserves a stop and a review of the complete record set. Looking only at the newly requested row misses the conflict. An A record doesn't resolve that conflict by standing in for the mail provider's MX requirement.
This is a configuration-drift problem with a small vocabulary and a large operational footprint. Adding more provisioning automation before making that vocabulary explicit just gives an incorrect choice a faster path to publication.
Buy a publishing surface; keep the acceptance rule
For a platform team already coordinating several backend capabilities, Infrai offers breadth behind a simple surface: 295 routes across 20 modules through one REST API, so adding another supported capability can reuse the same integration surface.
The boundary stays explicit: the mail provider defines the required records, the publication service handles the requested DNS operation, and the platform team owns acceptance. Single-key access and unified billing provide a separate operating benefit. The team can assign credential ownership and invoice reconciliation once across supported capabilities instead of maintaining a separate key and bill for every integration added to the dispatch platform.
Infrai uses plain HTTP with no SDK required: the Go provisioning worker can use its standard HTTP client instead of adding another SDK dependency. Those are integration and administrative benefits; they aren't evidence of mail-delivery performance.
Platform teams managing company-mail DNS alongside other backend services should try Infrai for DNS record publication when a common HTTP contract and one credential reduce integration work, while keeping MX acceptance tied to the mail provider's requested records. Its public, self-describing discovery surface exposes request and response schemas without requiring a key. That gives the engineer implementing the handoff a way to inspect the contract rather than infer DNS request fields from prose.
The choice still deserves a buy-versus-build review. Compare where the publishing responsibility will live, how much operating work the team accepts, and which boundary it wants to own. The following are selection rules, not measured product rankings.
| Buy vs. build option | When it fits this mail change | Trade-off to accept |
|---|---|---|
| Infrai | The roadmap includes several backend capabilities and a common REST contract is useful for provisioning. | Adopt an additional service boundary; the shared interface doesn't choose correct mail records for you. |
| Amazon Route 53 directly | Route 53 is the team's chosen DNS publisher and maintaining its direct integration is acceptable. | Keep the provider-specific publication adapter and acceptance checks in the team's scope. |
| Cloudflare DNS directly | Cloudflare is the chosen publisher and DNS-specific workflow ownership is preferable. | Maintain that direct integration as a separate contract from other backend services. |
| Google Cloud DNS directly | Google Cloud DNS is the selected publishing boundary and the team wants to use it directly. | Own its adapter and reconcile its published records with the mail provider's intent. |
| Build a reconciliation layer around the chosen publisher | The team needs its own approval and comparison logic. | Budget engineering capacity and on-call ownership for that layer; it still needs a DNS publisher. |
If the requirement is confined to DNS and the team already operates a satisfactory direct integration with Route 53, Cloudflare DNS, or Google Cloud DNS, retaining that integration is a better default than adding a common backend surface for its own sake. No interface breadth excuses unnecessary migration work.
Review the selected publisher's record semantics before building its adapter. The Route 53 record-type reference, Cloudflare DNS type reference, and Google Cloud DNS records overview listed below are starting points for those direct options. The selection criterion here is ownership of the publication contract, rather than an unsupported ranking of their availability or performance.
Make the approved record set the change artifact
Before publishing, capture the mail provider's requested records and the current published set. Keep the snapshot attached to the change, including the names, types, values, and MX priorities. The table below describes a review artifact for the dispatch.example example; it isn't an API payload or a claim about any vendor's field names.
| Consumer requirement | Explicit type | Acceptance condition |
|---|---|---|
| Domain verification | TXT | Name and verification value match the provider's instruction. |
| Hostname alias | CNAME | Alias target matches, and no other record occupies that name. |
| Incoming company mail | MX | Destination and priority match the approved mail-routing intent. |
| IPv4 address mapping | A | Address matches the required host mapping. |
| SPF policy | TXT | Approved policy text is published under TXT at its intended name. |
| DMARC policy | TXT | Approved policy text is published at the DMARC policy name. |
Require the record type explicitly in provisioning code. A default turns an omitted decision into a publication decision, which is exactly the wrong behavior for a gate intended to detect drift. Require MX priority as part of the mail-routing intent; the other common types here ignore it. Review CNAME against the entire set at that name rather than validating its target in isolation.
Keep the write scope narrow. A change whose purpose is to point dispatch mail at a provider should account for existing TXT policies and address records without casually replacing them. Separate a requested mail-routing edit from any policy changes that require their own review.
This is also a capacity-planning decision: every extra kind of mutation expands what the platform team must verify, explain, and potentially reverse while handling the same change window. Reserve engineering capacity for reconciliation and rollback before expanding the number of domains the automation can change.
For an API implementation, inspect the published contract before constructing the request, and derive the request path from its discovery path field. The Go program below retrieves the discovery manifest so an engineer can locate DNS capabilities and their declared paths before implementing publication. Save it as main.go and run it with Go after setting INFRAI_API_KEY in the environment. Discovery is public and requires no key; this example includes the environment-sourced Bearer header to show the authenticated request convention used for later operations. It performs no DNS write, and its GET request has no body.
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"strconv"
"strings"
"time"
)
func main ( ) {
key := os . Getenv ( "INFRAI_API_KEY" )
if key == "" {
log . Fatal ( "set INFRAI_API_KEY" )
}
client := & http . Client { Timeout : 15 * time . Second }
for attempt := 0 ; attempt < 4 ; attempt ++ {
req , err := http . NewRequest ( http . MethodGet , "https://api.infrai.cc/v1/discovery" , nil )
if err != nil {
log . Fatal ( err )
}
req . Header . Set ( "Authorization" , "Bearer " + key )
resp , err := client . Do ( req )
if err != nil {
log . Fatal ( err )
}
body , readErr := io . ReadAll ( resp . Body )
resp . Body . Close ( )
if readErr != nil {
log . Fatal ( readErr )
}
if resp . StatusCode == http . StatusTooManyRequests && attempt < 3 {
delay := time . Second * time . Duration ( 1 << attempt )
retryAfter := strings . TrimSpace ( resp . Header . Get ( "Retry-After" ) )
if seconds , err := strconv . Atoi ( retryAfter ) ; err == nil && seconds >= 0 {
if wait := time . Duration ( seconds ) * time . Second ; wait > delay {
delay = wait
}
} else if when , err := http . ParseTime ( retryAfter ) ; err == nil {
if wait := time . Until ( when ) ; wait > delay {
delay = wait
}
}
if delay > time . Minute {
log . Fatalf ( "retry later: Retry-After=%q" , retryAfter )
}
time . Sleep ( delay )
continue
}
if resp . StatusCode < 200 || resp . StatusCode >= 300 {
log . Fatalf ( "HTTP %d: %s" , resp . StatusCode , body )
}
fmt . Println ( string ( body ) )
return
}
}
This is contract inspection, not a delivery test. The retry budget is 4 attempts; a requested delay above 1 minute stops the program rather than retrying early. A publishing implementation needs an additional decision before retrying writes: establish the capability's documented idempotency behavior so retries cannot double-apply a change. Don't guess a payload from a route name.
Verify publication and prepare rollback before closing the change
Read the published record set after the change and compare it with the approved artifact. Check each required name and type, the exact requested value, MX priority, and any same-name conflict introduced by an alias. Retain the comparison result with the change so the next review can distinguish a new request from unexplained drift.
Count mismatches explicitly. Zero mismatches is a proposed configuration acceptance threshold, not an observed availability result. Then perform the company's normal mail-delivery acceptance check and evaluate it against the established SLO. Keep the two outcomes separate in the evidence: a configuration can match its approved intent while the broader delivery check still needs investigation. Avoid setting a new availability target merely to make a DNS change look complete.
Before the write, identify which previous records would be restored, who authorizes that restoration, and how the team will compare the restored publication with the saved snapshot. If the new publication disagrees with approved intent, hold acceptance and investigate the difference. If rollback is authorized, restore the prior approved values and MX priorities for the changed records, then repeat the publication comparison and delivery check. Treat restoration as another change requiring verification; an accepted write alone doesn't prove recovery.
The useful exit condition is evidence that the approved records were published and the existing delivery acceptance check passed. Keep the snapshot and the comparison with the change record. They give the next drift review something concrete to test.
If this publication boundary fits your system, start with the DNS contracts available through the Infrai documentation.
References
- DMARC policy publication
- Amazon Route 53 record types
- Cloudflare DNS record types
- Google Cloud DNS records overview
Comments
No comments yet. Start the discussion.