Set up email records

Last updated Apr 16, 2026 There are three reasons to set up email records for your domain:

The exact values for your DNS mail records depend on your email provider. If you have issues, review the Troubleshooting and contact your email service provider to confirm your DNS records are correct.


Receive email

If you only need to receive emails, Cloudflare offers Email Routing for free email forwarding to custom email addresses.

Send and receive email

To send and receive emails from your domain, you need an SMTP provider. Then, create two DNS records within Cloudflare, following the steps below:

  1. Get the IP address and MX record details from your SMTP provider (vendor-specific guidelines).
  2. Add an A or AAAA record for your mail subdomain that points to the IP address of your mail server.
Type Name IPv4 address Proxy status
A mail 192.0.2.1 DNS only

<details><summary>

Required API token permissions</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required: - <code>DNS Write</code></details>

Create DNS Recordbash

bash curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" \ --request POST \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --json '{ "type": "A", "name": "mail.example.com", "content": "192.0.2.1", "ttl": 3600, "proxied": false }'

Responsejson

json { "result": { "id": "<ID>", "zone_id": "<ZONE_ID>", "zone_name": "example.com", "name": "mail.example.com", "type": "A", "content": "192.0.2.1", "proxiable": true, "proxied": false, "ttl": 3600, "locked": false, "meta": { "source": "primary" }, "comment": null, "tags": [], "created_on": "2023-01-17T20:37:05.368097Z", "modified_on": "2023-01-17T20:37:05.368097Z" }, "success": true, "errors": [], "messages": [] }

</details>

  1. Add an MX record that points to that subdomain.
Type Name Mail server TTL Priority
MX @ mail.example.com Auto 5

<details><summary>

Required API token permissions</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required: - <code>DNS Write</code></details>

Create DNS Recordbash

bash curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" \ --request POST \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --json '{ "type": "MX", "name": "example.com", "content": "mail.example.com", "priority": 5, "ttl": 3600 }'

Responsejson

json { "result": { "id": "<ID>", "zone_id": "<ZONE_ID>", "zone_name": "example.com", "name": "example.com", "type": "MX", "content": "mail.example.com", "priority": 5, "proxiable": false, "proxied": false, "ttl": 3600, "locked": false, "meta": { "source": "primary" }, "comment": null, "tags": [], "created_on": "2023-01-17T20:54:23.660869Z", "modified_on": "2023-01-17T20:54:23.660869Z" }, "success": true, "errors": [], "messages": [] }

</details>

Note

If you encounter issues with your email setup, refer to our troubleshooting guide.


Prevent domain spoofing

Without email authentication records, anyone can send email that appears to come from your domain — a technique known as domain spoofing. To prevent this, you add DNS TXT records (text-based entries in your domain's DNS settings) that allow receiving mail servers to verify whether an email actually came from you:

Note

For additional background on email security records, refer to the introductory blog post ↗︎.

Configure email security records

Refer to Security records to learn how to set up your email security records.

Proxy SMTP traffic

By default, Cloudflare does not proxy email traffic on port 25 (SMTP). You can only proxy outgoing email if you have Spectrum configured for SMTP.

Was this helpful?

YesNo

On this page

Set up email records - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/dns/manage-dns-records/how-to/email-records/#page","headline":"Set up email records","description":"Configure MX, SPF, DKIM, and DMARC records for email.","url":"https://developers.cloudflare.com/dns/manage-dns-records/how-to/email-records/","inLanguage":"en","image":"https://developers.cloudflare.com/dns/manage-dns-records/how-to/email-records/og.png?v=8340d223965f40ff","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Import and export DNS records using zone files. title: Import and export records image: https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/og.png?v=6f581e20bbf5eb8d


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/dns/llms.txt
Use this file to discover all available pages before exploring further.