Best Practices for Configuring SPF with Cloudflare Proxy in 2026
Secure your email deliverability with proven SPF configuration best practices when using Cloudflare proxy.
Why does SPF break when using Cloudflare proxy?
You send a transactional email from your app, and it lands in the spam folder—despite having perfect content. You check your logs, and the error says: SPF fail. You’re confused. You’ve set up SPF correctly. So why is mail still blocked?
Cloudflare acts as a reverse proxy. It sits between your domain and the outside internet. When you send email through a service like SendGrid or AWS SES, Cloudflare’s IP appears as the sender—because it’s the one relaying the request. But email systems validate SPF records based on the actual sending IP. If your SPF record lists your email provider’s IP, but Cloudflare’s IP is making the outbound connection, the check fails. The result? Your emails get marked as suspicious or rejected entirely.
It’s not just a technical quirk—it’s a real bottleneck for deliverability. Without fixing it, you’ll see higher bounce rates, lower inbox placement, and growing problems with transactional and marketing sends. You’re not doing anything wrong—your setup is just misaligned with how email validation works.
Key takeaways
- Cloudflare’s proxy changes the outbound IP of email, causing SPF validation to fail when the sending IP isn’t in your SPF record.
- SPF checks on the actual sending IP—so if Cloudflare relays the email, your SPF record must include Cloudflare’s IPs or use a mechanism like SPF Alignment with a proxy-friendly setup.
- Ignoring this breakage leads to deliverability loss, especially for transactional or bulk email traffic relying on strict validation.
What is SPF, and why does it matter when using Cloudflare?
SPF is a DNS record that tells receiving mail servers which IP addresses are allowed to send emails from your domain. If your mail server’s IP isn’t listed in SPF, your emails risk being blocked or marked as spam. When using Cloudflare’s proxy, your outgoing mail often routes through Cloudflare’s IP addresses, so SPF must include them — otherwise, authentication fails.
How SPF works in the email delivery chain
SPF is one of the core email authentication protocols, alongside DKIM and DMARC. It’s checked early in the delivery process, during the SMTP handshake. If the sending IP isn’t authorized in the SPF record, the email is often rejected or flagged as suspicious.
Without SPF, spammers can easily forge your domain, hijacking your sender reputation and harming deliverability. A properly configured SPF record helps receivers trust that your emails are legitimate — a necessity when scaling outbound campaigns.
Why Cloudflare Proxy changes the SPF game
When Cloudflare proxies your website traffic, it also acts as an intermediary for outbound mail if you’re using their relay service (like in the Mailgun integration). This means the actual sending IP isn’t your server’s — it’s one of Cloudflare’s. If your SPF record only lists your original mail server, emails fail authentication.
Let’s say you send mail via a tool like SendGrid or Mailchimp, but their outgoing IPs aren’t in your SPF record. Even if the content is good, the receiver sees a mismatch and may reject the message. A common reason for high bounce rates or low inbox placement — especially for domains behind Cloudflare — is an outdated or incomplete SPF record.
The solution? Include Cloudflare’s IP ranges in your SPF record. For example: include:_spf.cloudflare.net. This tells receivers: “Yes, Cloudflare is authorized to send mail from this domain.” Use RFC 7208 as a reference for proper syntax and best practices around inclusion and limit checks (SPF has a 10 DNS lookup limit).
To make sure you’re not accidentally blocking valid mail, verify your SPF record with tools that test for alignment and compliance. You can check individual addresses before sending with our email checker, or validate entire lists using our bulk verification tool, which identifies delivery risks like invalid or misconfigured domains.
Best Practice 1: Do not use Cloudflare’s email proxy
You shouldn’t use Cloudflare’s proxy for email because it doesn’t handle email traffic at all—it only manages web requests. Trying to route mail through Cloudflare’s proxy breaks fundamental email delivery rules and will cause messages to fail or be flagged as spam. Always send email via a proper SMTP service like SendGrid, Mailgun, or AWS SES.
Why Cloudflare’s proxy doesn’t work for email
- Cloudflare’s proxy only processes HTTP/HTTPS traffic—email protocols like SMTP, IMAP, and POP3 are not supported.
- When you enable the proxy for an email domain, it doesn’t redirect mail; it only changes the web origin. Emails will still need an authorized mail server.
- Trying to send email through Cloudflare’s proxy results in delivery failures, DNS misconfigurations, and poor sender reputation.
What you should do instead
- Set up your email sending through a dedicated email service provider (ESP) like SendGrid, Mailgun, or AWS SES.
- Use your ESP’s recommended DNS records (SPF, DKIM, DMARC) to authorise their servers to send on your domain’s behalf.
- Keep Cloudflare’s proxy enabled for web traffic only, and ensure your mail server or ESP is publicly accessible via proper MX and A records.
- Never put your email domain’s MX or SPF records through Cloudflare’s proxy. That’s not how email routing works.
- Verify your email addresses before sending—misconfigured SPF isn’t your only risk. Use a service like MailTester’s email checker to validate addresses in real time.
Cloudflare’s proxy is not a mail relay. It was never designed to handle email delivery.
RFC 5321 (the core SMTP standard) defines mail transport rules that require explicit, authenticated sender infrastructure—something Cloudflare’s proxy doesn’t provide. If your email delivery fails, misconfigured SMTP routing is a top suspect. For a quick diagnostic, test your setup with a real-time inbox placement tool like MailTester’s inbox tester, which checks how your messages land in real inboxes. You can’t rely on Cloudflare’s proxy to make email work. It’s not built for it. Let your ESP handle the routing, and set up proper DNS records. This is how every large-scale email sender operates. If you’re still unsure, review the official SMTP specification or check how trusted providers like Google and Amazon handle outgoing mail.
Best Practice 2: Use Cloudflare for DNS only, not as an email gateway
Keep Cloudflare as your DNS provider but disable the proxy (orange cloud) on MX and TXT records. Let email systems see your real sending infrastructure—Cloudflare's proxy can break SPF, DKIM, and DMARC by rerouting email traffic through its IP addresses, which causes authentication failures.
How to apply this in practice
- Use Cloudflare for managing your DNS zone, including SPF, DKIM, and DMARC records.
- Never enable the orange cloud (proxy) on MX records. These must point directly to your email provider’s servers (e.g., SendGrid, Microsoft 365, Gmail).
- Do not proxy TXT records used for email authentication, such as SPF and DKIM. These must resolve to their intended values without Cloudflare's middleman.
- If you have multiple email providers, ensure each MX record points to the correct provider's IPs, not Cloudflare’s.
- Verify your setup using tools like MXToolbox or DMARC Analyzer to confirm records are published correctly and unmodified.
Why this matters for deliverability
When Cloudflare proxies email traffic, it changes the source IP of outgoing mail. SPF checks verify that the sending IP matches the domain’s published SPF record. If the actual IP is not in the SPF list (because Cloudflare’s proxy IP is used instead), the message fails SPF and gets marked as suspicious.
Even if DKIM is in place, SPF failures can still cause rejection—especially on strict filters used by Gmail and Microsoft. SPF (RFC 7208) requires the sender IP to be authorized in the domain’s SPF record, and proxying breaks this. DMARC also requires SPF or DKIM alignment, so a single failure can trigger a failure across the full stack.
Letting Cloudflare manage DNS but not email routing keeps your email infrastructure transparent. The sending IP remains your provider’s, the TXT records stay intact, and your authentication stack stays valid.
Before sending bulk campaigns, run a list through MailTester’s bulk verification to catch invalid, catch-all, or disposable addresses—preventing wasted sends and damaging sender reputation. Keep your SPF configuration clean and consistent across all mail systems.
Best Practice 3: Configure SPF to include your email provider’s IPs
You must include your email service provider’s domain in your SPF record using include: to authorize them to send emails on your behalf. Never add include:cloudflare.com — Cloudflare doesn’t send email for you, and doing so can break your SPF alignment. If you use SendGrid, add include:sendgrid.net; for AWS SES, use include:amazonses.com. These entries ensure your messages pass SPF checks and avoid being marked as spam.
Why your email provider’s IP matters
Your SPF record is a DNS-level gatekeeper that tells receiving mail servers, “Only these sources can send emails from my domain.” If your provider’s IP ranges aren’t explicitly allowed, even legitimate emails might be rejected or sent to spam. SPF is checked by every mail server that receives your message — it’s a core part of authentication, and one of the most common causes of delivery failure.
Let’s say you use SendGrid to send transactional emails. If your SPF record only lists your own infrastructure and not sendgrid.net, the receiving server will see an unauthorized sender and treat the message as suspicious. That means lower inbox placement, higher bounces, and damaged sender reputation. The fix is simple: include the provider’s domain in your record.
Cloudflare and SPF: what not to do
Cloudflare acts as a proxy for your web traffic — it doesn’t handle email. Including include:cloudflare.com in SPF does nothing useful and risks breaking alignment. It’s a common mistake, especially when people assume "proxy = email." The SPF specification explicitly states that includes should only reference services that send email on your behalf, not network proxies.
If you’re using a third-party email service, your SPF should look like this: v=spf1 include:sendgrid.net include:_spf.google.com -all. The order and structure matter — too many or conflicting includes can lead to SPF failures. Test your record using tools like MxToolbox or check it in real time with a service like MailTester’s inbox placement tester to validate deliverability before sending to real users.
Best Practice 4: Use a single SPF record per domain
You must have only one SPF record per domain. Multiple SPF records cause DNS validation to fail entirely, as resolvers ignore all records if more than one TXT record contains an SPF mechanism. Instead, combine all authorized senders—like your email service provider, marketing platform, and internal servers—into a single SPF record using include: or a: mechanisms to avoid failure.
Why multiple SPF records break email authentication
- Each domain can have only one valid SPF TXT record. If you have more than one, DNS resolvers discard all SPF data, resulting in SPF fail.
- SPF validation failure often leads to emails marked as spam or rejected outright, even if the sender is legitimate.
- Cloudflare’s proxy doesn’t change this rule—your SPF record must still be correct, even when traffic is routed through Cloudflare.
How to merge multiple senders into one SPF record
- Use the
include:mechanism to reference other organizations’ SPF records (e.g.,include:_spf.google.comfor Gmail users). - Use
a:to authorize the domain’s A record IP addresses, which works for internal mail servers. - Keep the total length of your SPF record under 255 characters to avoid truncation issues—exceeding this can break SPF validation.
- Test your SPF record using tools like MxToolbox or SPFCheck.org to verify it parses correctly and doesn’t trigger an error.
Let’s say you use Cloudflare for DNS, SendGrid for transactional emails, and your company’s on-premise server for internal mail. You don’t need three separate SPF records. Instead, combine them: v=spf1 include:sendgrid.net a:mail.yourcompany.com ~all.
If you're managing a large email ecosystem or using multiple platforms, consider using a tool to validate SPF records in bulk. That way, you catch configuration errors before they cause deliverability issues. MailTester’s bulk verification helps you audit and clean high-volume email lists to ensure sender alignment.
Best Practice 5: Avoid overly long or complex SPF records
SPF records can only make up to 10 DNS lookups during validation. Each include: or a: tag counts as one lookup. If your record exceeds that limit, it fails silently — and your emails may be rejected. Keep it simple: list only essential senders and use providers with built-in SPF support.
How SPF lookups work
- Every
include:directive triggers a DNS query to fetch another SPF record. - Each
a:orip4:entry also counts toward the 10-lookup limit. - Complex records with multiple includes (e.g., for old tools, marketing platforms, and internal systems) risk hitting the limit—even if they’re valid.
Prioritize simplicity and reliability
- Only include trusted, active sending sources. Remove old or unused entries.
- Use third-party services that handle SPF on their end — like Mailchimp, HubSpot, or SendGrid — which already have SPF mechanisms in place.
- When you must add a new sender, test the full SPF record using tools like MXToolbox or RFC 7208 to verify you’re under the 10-lookup limit.
- Prefer
include:only when necessary; avoid chaining multiple includes. - If you're managing SPF across many domains, use a centralized tool to audit and validate records regularly.
- Use MailTester’s email checker to verify sender addresses before sending — it checks for SPF, DNS, and deliverability risks in real time, helping you prevent abuse of complex setups.
SPF failures due to excessive lookups often go unnoticed but can silently block legitimate emails from reaching inboxes.
Let’s be honest: complexity is the enemy of deliverability. A clean, minimal SPF record isn’t just safe — it’s predictable. And predictability reduces email failure rates at scale.
Best Practice 6: Set up DMARC to monitor SPF failures
You should set up DMARC with a policy of p=none to collect reports on SPF and DKIM failures without blocking emails. This lets you see how SPF misconfigurations impact deliverability, especially when using Cloudflare’s proxy, before enforcing stricter policies. Use inbox placement testing tools like MailTester to validate how your authentication setup affects real-world delivery.
How DMARC uses SPF and DKIM results
DMARC builds on SPF and DKIM by evaluating their results and applying a policy you define. If SPF or DKIM fail, DMARC determines what to do—quarantine, block, or do nothing—based on your policy. Without DMARC, even properly configured SPF won’t provide enforcement or visibility into what’s going wrong with your mail flow.
When Cloudflare proxies your domain, it changes the envelope sender IP, which can break SPF if not handled correctly. DMARC reports help you see these failures in real time. The reports include details like the source IP, failed authentication method, and receiving domain. This data is essential for debugging delivery issues that stem from misconfigured forwarding or third-party services.
Start with p=none for visibility
Set your DMARC policy to p=none initially. This means no emails are blocked, but you’ll receive aggregate and forensic reports from receiving providers. These reports reveal how many messages from your domain failed SPF or DKIM checks—especially useful when Cloudflare is handling traffic.
Use tools like MailTester’s inbox placement testing to check how your email performs in real inboxes. This simulates delivery through major providers and confirms whether SPF failures are causing mail to land in spam or be rejected. You can run these tests across Gmail, Outlook, and Yahoo to get a full picture of how your config holds up in practice.
Once you’ve reviewed reports and confirmed that your SPF setup is solid (especially for outbound services through Cloudflare), you can gradually tighten your DMARC policy—first to p=quarantine, then to p=reject. But don’t skip the monitoring phase. A single misconfigured service or forwarding rule can cause mass delivery failures if DMARC is enforced too early.
For ongoing checks, consider using MailTester’s email checker to validate individual addresses before sending. This complements DMARC by catching invalid or risky addresses early, reducing the chance of bounce-related reputation issues.
DMARC is not a magic fix—it’s a monitoring and enforcement layer. When paired with accurate SPF configuration and tools that test real delivery, it becomes a powerful defense against spoofing and poor deliverability. The core of success is visibility: see what’s failing, fix it, then enforce.
Best Practice 7: Use mail verification tools to validate SPF and deliverability
You can catch SPF misconfigurations early by verifying email addresses before sending. Tools like MailTester check whether an address is likely to receive mail by analyzing real delivery behavior, including bounce patterns and inbox placement—indirect but reliable signals of SPF and authentication issues. With a 98.9% accuracy rate, it reflects actual delivery conditions across major providers.
How SPF issues show up in real-world delivery
SPF isn't checked in isolation. When an email fails SPF, it often bounces or lands in spam. But not every bounce is visible at first—some are delayed, greylisted, or silently rejected. This is why testing delivery behavior, not just syntax, matters. MailTester’s inbox placement tests simulate real sending and measure how likely an email is to reach the inbox.
Let’s say you’ve set up Cloudflare proxy for your domain and enabled SPF. Even if the record looks correct, it might not be fully effective if the sender IP isn’t authorized, or if DMARC policies are too strict. MailTester doesn’t directly scan SPF records—but it detects flaws by observing what actually happens when an email is sent. A high bounce rate or poor inbox placement on a domain-wide scale can point to authentication missteps not visible through DNS inspection alone.
Integrate verification into your workflow
Use the real-time verification API to validate addresses as they enter your system, or run bulk list checks on your entire mailing list before campaigns. This filters out addresses that will fail due to SPF, role accounts, or disposable domains—before they hurt your sender reputation.
For example, a single invalid address with a malformed SPF alignment can trigger a reject or rate limit from providers like Gmail or Outlook. Testing at scale reduces that risk. MailTester’s accuracy is based on real-world feedback loops, not just pattern matching. It’s not just checking syntax—it’s simulating real delivery conditions. The inbox placement tester lets you verify how your sending practices are perceived by actual mail providers, including how SPF and DKIM affect delivery.
As RFC 7208 states, SPF is designed to prevent sender forgery, but it depends on correct implementation across the entire email transaction chain. You can’t rely on DNS alone. Tools that test actual delivery behavior—like MailTester—help close that gap. Use them not as a supplement, but as the final check before sending.
Best Practice 8: Test SPF configuration across real inboxes
You can't prove your SPF setup works just by checking DNS records. Even if your TXT records are correct, real inboxes like Gmail, Outlook, and Yahoo may still reject your email based on how your full authentication stack (SPF, DKIM, DMARC) performs in practice. The only way to know is to send real test emails to actual inboxes and see if they arrive — and catch any issues before your real campaign launches.
Why DNS checks aren't enough
DNS validation tools will confirm your SPF record is syntactically correct. But they can’t tell you whether a receiving mail server will accept your message in an actual delivery environment. Factors like DMARC policy enforcement, inconsistent DKIM signing, or third-party forwarding can block your email even with proper SPF configuration.
According to RFC 7208, SPF only defines sender authorization at the envelope level; it doesn’t guarantee inbox delivery. Real-world filtering happens at the message level, where DMARC and DKIM interact. That’s why you need in-product testing that simulates real user inboxes.
- Send test emails to real inboxes via MailTester’s inbox placement tool — Use the inbox placement tester to dispatch authenticated messages to Gmail, Outlook, Yahoo, and other major providers. This reveals exactly which filters are blocking your message and why.
- Check for SPF, DKIM, or DMARC failures in the results — The test report breaks down why each inbox rejected (or accepted) your email. If your SPF fails, it may be due to a missing include, a malformed mechanism, or a proxy mismatch when using Cloudflare.
- Verify each domain in your Cloudflare proxy setup — If you're using Cloudflare’s proxy (orange cloud), ensure your SPF record doesn’t include a
include:cloudflare.comtag unless explicitly needed. Over-reliance on such includes can break SPF when the IP changes unexpectedly. - Use the MailTester API to test sender reputation at scale — For large senders, automate inbox placement tests with the real-time verification API. This allows you to catch SPF-related issues before sending to your full list.
- Review and adjust SPF after testing — If your test emails fail SPF validation, update your TXT record to fix mechanisms, remove outdated includes, or use a more reliable alignment strategy. Always re-test after changes.
Let’s be clear: no single check is sufficient. You need DNS validation, but you also need to test across real inboxes. SPF misconfigurations often go unnoticed until volume increases and deliverability drops — that’s why proactive inbox testing is not optional.
The only way to catch these issues early is through tools that send real messages through actual email infrastructure. MailTester’s inbox placement testing gives you that visibility, down to the exact failure reason per provider.
How to fix SPF when your email isn’t reaching inboxes
SPF errors often stem from multiple TXT records or incorrect inclusion of Cloudflare in your SPF setup. Ensure your domain has exactly one SPF TXT record, and that it only lists legitimate email sources—your email provider, not Cloudflare.
Verify the fix in real-world conditions
Use MailTester’s real-time verification API to test a small batch of email addresses. This confirms whether your SPF configuration allows delivery to actual inboxes, not just test environments.
Monitor long-term delivery success
Enable DMARC reporting to track SPF and DKIM alignment across real email flows. Consistent passing results indicate your SPF is correctly configured and trusted by mail providers.
Sources
- The effective spam-complaint target for 2026 has tightened to below 0.1%, down from the historical 0.2–0.3% tolerance, as mailbox providers raise the bar for senders. — Validity 2026 Email Deliverability Benchmark Report (via The Agile Brand Guide) (2026)
- Warming up a new domain for 4–6 weeks before full-volume sending reduces spam placement by up to 35%. — Lemlist data (via WarmForge deliverability statistics) (2025)
Keep reading
- Anti-spam laws and compliance: CAN-SPAM, GDPR, CASL (complete guide)
- How to Handle Forgotten Consent Under Australian Spam Act 2026
- How to Properly Set Up Email Records with Cloudflare Proxy Enabled
- How to Prove Email Consent Under Australian Spam Act 2003
- Email Deliverability Tools That Ensure Australian Spam Act Adherence
Ready to put this into practice? MailTester verifies emails with 98.9% accuracy — start with 100 free verifications.
Frequently asked questions
Can I use Cloudflare as an email relay?
No. Cloudflare does not provide email relay services. It only handles web traffic and DNS. Email must be sent via an authorized SMTP provider.
Why is my SPF failing when using Cloudflare?
SPF fails because Cloudflare’s proxy does not send email. If your SPF record lists Cloudflare IPs as senders, it will fail. Use only your email provider’s IPs in SPF.
Do I need to remove Cloudflare proxy from my MX records?
Yes. MX records must point to your email provider’s servers, not Cloudflare. Enabling the orange cloud on MX records breaks email delivery.
Can I combine Cloudflare with SPF for email security?
Cloudflare secures your website, not your email. SPF must be configured independently using your email provider's authorized IPs. Use tools like MailTester to test delivery health.
What happens if I have multiple SPF records?
DNS resolvers will ignore all SPF records and treat SPF as a failure. This harms deliverability. Merge all senders into one TXT record using `include:` mechanisms.
How do I know if SPF is working?
Use MailTester’s inbox placement testing to send test emails. Check DMARC reports for SPF pass/fail rates. Monitor bounce logs for permanent failures.
Can I use MailTester to catch SPF issues before sending?
Yes. MailTester’s bulk verification and real-time API flag invalid, risky, or catch-all addresses. It identifies list issues that can result from SPF misconfigurations.
Does Cloudflare affect DKIM or DMARC?
Cloudflare does not affect DKIM or DMARC directly. But if it proxies email traffic, it breaks the chain. Ensure email is sent via your provider, not Cloudflare.
Should I use a different DNS provider for email?
Not necessary. You can use Cloudflare for DNS. Just don’t proxy MX records. Keep your email provider’s IP addresses in SPF and ensure records are valid and single.
What’s the impact of a failed SPF check?
Emails are more likely to be blocked, marked as spam, or rejected by recipient servers. This reduces inbox placement, especially with Gmail, Yahoo, and Outlook.
How accurate is MailTester’s deliverability testing?
MailTester delivers 98.9% accuracy in email verification and inbox placement testing. It uses real email inboxes and monitors real results, not predictions.
Can I test SPF with a free tool?
Free tools like MXToolbox or Google’s Postmaster Tools offer basic checks. But for real inbox performance, use a service like MailTester with actual inboxes and verification data.