Setting Up SendGrid Email Authentication
Complete guide to configuring SPF, DKIM, and DMARC for SendGrid transactional and marketing emails.
Setting Up SendGrid Email Authentication
SendGrid is a popular transactional and marketing email service. This guide covers setting up SPF, DKIM, and DMARC for SendGrid.
Prerequisites
- SendGrid account
- Domain verified in SendGrid
- Access to your domain's DNS settings
- MailSentinel account for DMARC monitoring
Overview
SendGrid requires:
- SPF - Authorize SendGrid to send emails
- DKIM - Sign emails with SendGrid's keys
- DMARC - Monitor and enforce authentication
Step 1: Add Domain to SendGrid
- Log in to SendGrid Dashboard
- Go to Settings → Sender Authentication
- Click Authenticate Your Domain
- Enter your domain (e.g.,
example.com) - Choose authentication method:
- Domain Authentication (recommended)
- Link Branding (for subdomains)
Step 2: Configure SPF for SendGrid
Get SendGrid SPF Include
SendGrid provides this SPF include:
include:sendgrid.netBuild Your SPF Record
If SendGrid is your only email service:
v=spf1 include:sendgrid.net -allIf you use other services (Google Workspace, etc.):
v=spf1 include:_spf.google.com include:sendgrid.net -allImportant: Only ONE SPF record per domain. Merge all includes into a single record.
Add SPF Record to DNS
DNS Record Details:
- Type: TXT
- Host:
@or leave blank (root domain) - Value: Your complete SPF record
- TTL: 3600 (1 hour)
Verify SPF Setup
- In SendGrid dashboard, check domain status
- Use MailSentinel to verify SPF record
- Use MXToolbox SPF checker
Step 3: Configure DKIM for SendGrid
Get DKIM Records from SendGrid
SendGrid automatically generates DKIM keys:
- In SendGrid dashboard, go to Settings → Sender Authentication
- Find your authenticated domain
- Click View Details or Edit
- You'll see DKIM records like:
Host: s1._domainkey
Type: TXT
Value: k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC...
Host: s2._domainkey
Type: TXT
Value: k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC...
Add DKIM Records to DNS
For each DKIM record:
-
Add TXT record to your DNS:
- Host:
s1._domainkey(ors2._domainkey) - Type: TXT
- Value: The complete DKIM value provided by SendGrid
- TTL: 3600
- Host:
-
Repeat for all DKIM selectors (usually 2)
Verify DKIM Setup
In SendGrid Dashboard:
- Status should show "Verified" or green checkmark
- May take 15-60 minutes to verify
Manual Verification:
- Send test email through SendGrid
- Check email headers
- Look for
DKIM-Signatureheader - Verify signature is valid
Step 4: Configure DMARC for SendGrid
Get Your MailSentinel Report Address
- Log in to MailSentinel
- Add your domain
- Go to Settings → DMARC Configuration
- Copy report address:
your-org-id@reports.mailsentinel.io
Create DMARC Record
Starting with monitoring:
v=DMARC1; p=none; rua=mailto:your-org-id@reports.mailsentinel.ioAfter monitoring (quarantine):
v=DMARC1; p=quarantine; rua=mailto:your-org-id@reports.mailsentinel.io; adkim=r; aspf=rFull protection:
v=DMARC1; p=reject; rua=mailto:your-org-id@reports.mailsentinel.io; ruf=mailto:your-org-id@forensic.mailsentinel.io; adkim=r; aspf=rAdd DMARC Record to DNS
DNS Record Details:
- Type: TXT
- Host:
_dmarc - Value: Your complete DMARC record
- TTL: 3600
Verify DMARC Setup
- Use MailSentinel to check DNS
- Verify DMARC record is detected
- Wait 24-48 hours for first reports
- Monitor in MailSentinel dashboard
SendGrid-Specific Considerations
Domain Authentication vs Link Branding
Domain Authentication:
- Full domain authentication
- Required for SPF/DKIM
- Use for sending domain
Link Branding:
- For click tracking links
- Optional but recommended
- Uses subdomain (e.g.,
click.example.com)
SendGrid IP Addresses
If you need to whitelist IPs:
- SendGrid uses shared IP pools
- Don't add individual IPs to SPF
- Use
include:sendgrid.netinstead
SendGrid Subaccounts
If using subaccounts:
- Each subaccount can use same domain
- SPF/DKIM/DMARC apply to all
- No additional configuration needed
SendGrid Webhooks
For DMARC monitoring:
- SendGrid doesn't send DMARC reports
- Use MailSentinel for DMARC monitoring
- SendGrid sends via receiving servers
Common SendGrid Configurations
SendGrid Only
SPF:
v=spf1 include:sendgrid.net -allDKIM: Configure in SendGrid dashboard
DMARC:
v=DMARC1; p=none; rua=mailto:your-org-id@reports.mailsentinel.ioSendGrid + Google Workspace
SPF:
v=spf1 include:_spf.google.com include:sendgrid.net -allDKIM: Configure both Google Workspace and SendGrid DKIM
DMARC: Same as above, covers both services
SendGrid + Multiple Services
SPF:
v=spf1 include:_spf.google.com include:sendgrid.net include:servers.mcsv.net -allDKIM: Configure for each service
DMARC: Single DMARC policy covers all
Troubleshooting SendGrid Issues
Issue 1: SPF Not Working
Symptoms:
- Emails failing SPF check
- SendGrid shows authentication errors
Solutions:
- Verify SPF record includes
include:sendgrid.net - Check only one SPF record exists
- Verify DNS propagation (wait 15-60 minutes)
- Use SPF checker to validate
Issue 2: DKIM Not Signing
Symptoms:
- No DKIM signature in headers
- SendGrid shows DKIM not verified
Solutions:
- Verify DKIM records are published in DNS
- Check selector matches SendGrid's expectation
- Wait for DNS propagation
- Verify domain is authenticated in SendGrid
- Check for typos in DNS records
Issue 3: DMARC Failures
Symptoms:
- DMARC reports show failures
- Emails going to spam
Solutions:
- Verify SPF alignment
- Verify DKIM alignment
- Check From: domain matches authenticated domain
- Review DMARC reports for details
- Fix underlying SPF/DKIM issues
Issue 4: Domain Not Verifying
Symptoms:
- SendGrid shows domain not verified
- DNS records not detected
Solutions:
- Wait 15-60 minutes for DNS propagation
- Verify DNS records are at correct location
- Check for typos in records
- Ensure nameservers are correct
- Try removing and re-adding domain
Best Practices for SendGrid
1. Use Dedicated Subdomain
For Transactional Email:
- Use subdomain like
mail.example.com - Isolates reputation
- Easier to manage
SPF for Subdomain:
mail.example.com TXT "v=spf1 include:sendgrid.net -all"2. Monitor Authentication
Key Metrics:
- SPF pass rate (target: 95%+)
- DKIM pass rate (target: 95%+)
- DMARC pass rate (target: 95%+)
- Bounce rate (target: <5%)
3. Regular Audits
Quarterly Reviews:
- Check SPF includes still needed
- Verify DKIM keys are valid
- Review DMARC reports
- Update records as needed
4. Test Before Production
Before Going Live:
- Send test emails
- Verify authentication headers
- Check DMARC passes
- Test with multiple providers
5. Use MailSentinel for Monitoring
Benefits:
- Centralized DMARC monitoring
- Alerts for authentication failures
- Detailed reporting
- Progress tracking
SendGrid API Integration
Sending Emails via API
Authentication:
- SendGrid API uses same domain authentication
- SPF/DKIM/DMARC apply to API emails
- No additional configuration needed
Webhook Configuration
For Bounce/Spam Tracking:
- Configure SendGrid webhooks
- Monitor bounce rates
- Track spam complaints
- Keep spam rate below 0.3%
Next Steps
After setting up SendGrid authentication:
- Monitor DMARC Reports - Track authentication status
- Set Up Alerts - Get notified of issues
- Review Best Practices - Optimize deliverability
- Troubleshoot Issues - Fix any problems
Additional Resources
- SendGrid Documentation - Official SendGrid guides
- SendGrid Domain Authentication - Domain setup guide
- SPF Configuration Guide - Complete SPF setup
- DKIM Configuration Guide - Complete DKIM setup
- DMARC Configuration Guide - Complete DMARC setup