SendGrid
SendGrid SPF record: set up SPF, DKIM and DMARC
Where the SendGrid SPF record lives, the CNAMEs Domain Authentication creates, the s1 and s2 DKIM selectors, and how to add DMARC safely.
Check your current setup:
How the SendGrid SPF record works
The SendGrid SPF record sits on a subdomain of yours, such as em1234.example.com. You create it with Domain Authentication, the SendGrid feature that also sets up DKIM, a signature that lets receivers confirm a message was not altered in transit.
SendGrid sets the Return-Path (the hidden address that collects bounces) to that subdomain. Receivers check SPF against the Return-Path, so they read the record on em1234.example.com. Your root SPF record stays as it is.
Automated security is on by default. You publish CNAME records, which point one name at another, and SendGrid maintains the SPF and DKIM data behind them. It can update that data when you add a dedicated IP address. With automated security off, you publish the MX and TXT records yourself and change them whenever your sending setup changes.
Step 1: Start domain authentication
- In the Twilio SendGrid console, go to Settings > Sender Authentication.
- In the Domain Authentication section, click Get Started.
- Choose your DNS host under Which Domain Name Server (DNS) host do you use? and say whether you also want to brand your links. Click Next.
- In Domain You Send From, type the domain that appears in your From address. Twilio asks for the root domain, without
wwworhttp://. - Open Advanced Settings. Leave Use automated security checked unless your DNS host does not accept underscores in CNAME records. Click Next.
If GoDaddy hosts your DNS, automated security is on and you skipped link branding, SendGrid can offer automated setup through Domain Connect. You log in to GoDaddy, approve the change and SendGrid configures the DNS. Automated setup and automated security are separate options. In other cases you use the Manual Setup tab and copy the records by hand.
Step 2: Publish the DNS records
The Install DNS Records page lists four records. Three are CNAMEs like these:
em1234→u1234567.wl123.sendgrid.net(Return-Path and SPF)s1._domainkey→s1.domainkey.u1234567.wl123.sendgrid.net(DKIM)s2._domainkey→s2.domainkey.u1234567.wl123.sendgrid.net(DKIM)
These values are examples. Copy the ones SendGrid shows for your account into your DNS panel, then click Verify. The fourth record is the DMARC record covered in step 3. If you chose link branding, the page also lists two CNAMEs for your links. SendGrid generates the em1234 label. Use a custom return path, under Advanced Settings, lets you choose another one. A label that matches an existing CNAME overwrites that record, so check your DNS first.
SendGrid DKIM selectors
s1 and s2 are the default DKIM selectors, the names that tell a receiver which key to fetch. SendGrid activates one selector at a time and rotates between them when necessary, so keep both published. These records live on your domain. Once it is verified, a message whose From domain matches is signed with your domain in d=, which lets DKIM align with your From address. Until then, SendGrid uses sendgrid.net, which does not align with your domain.
With automated security off
SendGrid gives you three records instead of the CNAMEs:
- MX on
em1234.example.com→mx.sendgrid.net - TXT on
em1234.example.com→v=spf1 include:sendgrid.net ~all - TXT on
m1._domainkey.example.com→ the DKIM key, starting withk=rsa; t=s; p=
include:sendgrid.net is the SPF include SendGrid documents, and it goes on the em subdomain. Twilio's SPF page shows an example ending in -all, and the setup page uses ~all. Copy the value your console shows. You also keep these records up to date yourself from then on.
Step 3: Add the SendGrid DMARC record
SendGrid's fourth record is a TXT record on _dmarc with the value v=DMARC1; p=none;. That value requests no reports. Add your reporting address to the existing policy, or use the monitoring example below only for a first policy.
Use this starter value only if no DMARC policy exists at this name. Otherwise edit the existing record, preserving its p=, alignment settings and report addresses; add your monitored rua destination there. Never create a second policy record.
v=DMARC1; p=none; rua=mailto:dmarc@example.com
Replace the address with your DMARC Pulse reporting address. The rua tag asks mailbox providers for aggregate reports, defined in RFC 9990, which show the servers sending mail as your domain. p=none asks them to take no DMARC action while you collect those reports.
Keep a single DMARC record. If your domain already has one, edit it. RFC 9989 section 4.10 tells receivers to discard every record when they find more than one at the same name.
DMARC needs SPF or DKIM to pass on a domain that aligns with your From address. RFC 9989 makes relaxed alignment the default for both, so a subdomain counts when it shares your organizational domain. SendGrid fits that rule twice: SPF aligns through em1234.example.com and DKIM aligns through d=example.com.
Preserve your existing aspf setting. A Return-Path subdomain may fail strict SPF alignment, but passing exact-domain DKIM still suffices for DMARC. Any move to relaxed alignment is a deliberate domain-wide policy choice.
Step 4: Check, then enforce
Send a test message to a mailbox you control and paste its headers into the Email Header Analyzer. You should see spf=pass for the em subdomain, dkim=pass for your domain and dmarc=pass. The DKIM-Signature header shows your domain in d= and the active selector in s=. You can also run the SPF checker on the em subdomain and the DKIM checker with selector s1 or s2, or m1 with automated security off.
Keep the existing policy, alignment settings and report destinations as you authenticate SendGrid. A first policy can start at p=none. Use the reports to inventory every legitimate sender on the domain, including rare and seasonal mail, before considering quarantine. Reject needs a separate manual decision that accounts for mailing lists and forwarding; it is optional, and receivers decide delivery.
Common problems
- Records stay unverified after you publish them. Validation can take up to 48 hours. If only some records verify, wait, then look for a mistyped value.
- Your DNS host appends the domain. GoDaddy, Amazon Route 53 and Namecheap can add your domain to the name you type, which produces
em1234.example.com.example.com. Type only the host,em1234. DNS Validation Error (Code: 1004)on a Cloudflare domain. New CNAME records can default to Proxied, and proxied CNAMEs are not visible publicly. Switch each SendGrid record to DNS only.- Another record exists at a CNAME name. Identify the service using it first. Do not delete active MX/TXT/CNAME records blindly. Choose a free account-supported name or coordinate a migration with that signer before replacing its DNS.
- Your DNS host rejects underscores. SendGrid's records need them. Turning off automated security helps only if the host accepts underscores in TXT names, because the DKIM record on
m1._domainkeycontains one too. Otherwise SendGrid suggests considering another DNS host. Expected TXT record atappears with automated security off. Your DKIM key was split into several quoted parts. Join it back into one string.- Verification succeeded but DMARC shows a failure. SendGrid does not need a DMARC pass to complete Domain Authentication. The Install DNS Records page marks the failure and you can still send, so fix the
_dmarcrecord with your DNS host. - Mail still shows
via sendgrid.net(orvia eu.sendgrid.neton Regional accounts), or DMARC fails for some messages. SendGrid applies an authenticated domain when it matches the From address. With no match it uses your default authenticated domain, and failing that,sendgrid.net. A subuser looks for its own matching domain, then its own default, then a domain the parent account assigned to it. Subdomains do not inherit authentication from their parent, so authenticate each domain you send from. - You send from an address such as
@yahoo.com. Yahoo's records do not authorize SendGrid, so SPF and DKIM both fail and the receiver applies Yahoo's DMARC policy. You may see521 5.2.1 : (DMARC) This message failed DMARC Evaluation and is being refused due to provided DMARC Policy, and SendGrid tracks it as a Block. Send from a domain you authenticated. - Strict SPF alignment fails. Keep the policy and confirm passing DKIM with
d=matching From. If SPF alignment is also required, assess an account-specific custom return path matching the From domain. Preserve Sender is a support-only last resort: you must then manage bounces, spam feedback and suppressions. Relaxingaspfis optional and affects all senders. - You only verified a single sender. Single Sender Verification confirms that you own one address. Twilio says it works for testing only and tells you to complete Domain Authentication before you send in production.
- Your DKIM key is still 1024 bits. Twilio says existing setups do not change on their own, and that a first Domain Authentication created after May 2021 already has a 2048-bit key. To move an older one, authenticate the domain again with a custom DKIM selector, confirm the new setup works, then delete the old one.
- The same domain sits on two accounts or subusers. Under Advanced Settings, check Use a custom DKIM selector on the second one and type three letters or numbers, such as
orgor001. Its DKIM CNAMEs then stop colliding with the first set.