DNS for Forward Email
Take every name and value from the Forward Email domain object (getDomain / GET /v1/domains/:domain):
verification_recordis the token for the TXT valueforward-email-site-verification=<token>.smtp_dns_records.dkimis{ name, value }and becomes a TXT record.smtp_dns_records.return_pathis{ name, value }and becomes a CNAME, usuallyfe-bounces→forwardemail.net.smtp_dns_records.dmarcis{ name, value }and becomes a TXT record, usually at_dmarc.
Names are relative to the zone. For a subdomain such as mail.example.com in the example.com zone, the API returns names like _dmarc.mail, and the MX, verification TXT and SPF records go on the mail host.
Fixed records:
- MX
@→mx1.forwardemail.net(priority 0) - MX
@→mx2.forwardemail.net(priority 0) - TXT
@→v=spf1 include:spf.forwardemail.net -all(merge into an existing SPF record rather than adding a second one)
Optional: CNAME autoconfig → autoconfig.forwardemail.net and CNAME autodiscover → autodiscover.forwardemail.net. These let email clients configure themselves.
Before writing anything
- Read the current records for
@,_dmarcand the DKIM and Return-Path names. - If MX already points somewhere else, the domain receives mail today. Confirm with the user before replacing it. To keep it and only send, skip the MX records and set
ignore_mx_check: trueon the domain. - If there is already an SPF record, add
include:spf.forwardemail.netto it rather than creating a second one. - If there is already a DMARC record, or other services send as this domain, show the values and ask which policy to use.
p=noneandp=quarantinealso pass verification.
Writing records automatically
Use whatever access the environment already has: a DNS provider MCP server, the provider's official CLI, or its REST API with a token from an environment variable. Look up the exact syntax in the provider's own docs. Never guess at flags.
Cloudflare REST API example
# Needs CLOUDFLARE_API_TOKEN with Zone → Zone → Read and Zone → DNS → Edit,
# or set CLOUDFLARE_ZONE_ID yourself and skip the lookup.
DOMAIN=example.com
CF="https://api.cloudflare.com/client/v4"
AUTH="Authorization: Bearer $CLOUDFLARE_API_TOKEN"
ZONE_ID=${CLOUDFLARE_ZONE_ID:-$(curl -fsS "$CF/zones?name=$DOMAIN" -H "$AUTH" | jq -r '.result[0].id')}
[ -n "$ZONE_ID" ] && [ "$ZONE_ID" != null ] || { echo "zone not found for $DOMAIN" >&2; exit 1; }
add() { curl -fsS -X POST "$CF/zones/$ZONE_ID/dns_records" -H "$AUTH" \
-H "Content-Type: application/json" --data "$1" >/dev/null && echo "added: $1"; }
add '{"type":"MX","name":"'$DOMAIN'","content":"mx1.forwardemail.net","priority":0,"ttl":3600}'
add '{"type":"MX","name":"'$DOMAIN'","content":"mx2.forwardemail.net","priority":0,"ttl":3600}'
add '{"type":"TXT","name":"'$DOMAIN'","content":"forward-email-site-verification=TOKEN","ttl":3600}'
# The Return-Path CNAME must be DNS-only:
add '{"type":"CNAME","name":"fe-bounces.'$DOMAIN'","content":"forwardemail.net","proxied":false,"ttl":3600}'Cloudflare expects full record names that include the zone (for example fe-bounces.example.com). Add the SPF, DKIM and DMARC TXT records the same way, using the values from the domain object.
Verify with backoff
Run both checks; verify-smtp doesn't depend on verify-records.
check() { # retries after 15 s, 30 s, 60 s, then every 2 minutes; about 15 minutes in total
for wait in 15 30 60 120 120 120 120 120 120 0; do
curl --fail-with-body -sS -u "$FORWARD_EMAIL_API_KEY:" \
"https://api.forwardemail.net/v1/domains/$DOMAIN/$1" && return 0
echo; sleep "$wait"
done
return 1
}
check verify-records; check verify-smtp- When a check fails, the response text says which record is missing or wrong. Fix it, then run the check again.
- When
verify-smtppasses, domains that pass Forward Email's automatic checks get outbound SMTP right away.getDomainthen showshas_smtp: true. - Other domains get a manual review: most within 1–2 hours, typically under 24. The domain admins are emailed, and Forward Email may ask for details.