A digital illustration for a blog post header. The title at the top reads "Hetzner Email Hosting with Cloudflare DNS". Below, an orange cloud icon labeled "Cloudflare DNS" on the left is connected by a glowing arrow to a blue envelope icon with a shield in the center. Another glowing arrow connects the envelope to a blue server rack icon labeled "Hetzner Email Hosting" on the right, all against a dark background split diagonally between black and blue.

Hetzner Email, Cloudflare DNS: The Ultimate Setup Guide

by

in ,

Read Time

2–3 minutes

Using Hetzner Web Hosting for its rock-solid reliability but managing your DNS through an external provider like Cloudflare for speed and features? You’re not alone! The trickiest part is ensuring your external DNS records—especially the MX, SRV, and TXT records—are perfectly matched to what Hetzner requires.

This guide walks you through configuring your external DNS to keep your email running seamlessly through your Hetzner Webhosting package.

1. Important Note on Cloudflare Proxying

When setting up email records in Cloudflare, you must ensure the proxy status (the orange cloud icon) is set to DNS Only (Grey Cloud). Email traffic cannot be proxied through Cloudflare’s network, or it will fail.

2. Setting the Mail Exchange (MX Record)

The MX record tells the internet where to send mail destined for your domain (immanuelraj.dev in this example). You should only have this single MX record for Hetzner to ensure all mail is routed correctly.

TypeNameContent (Mail Server)PriorityTTLProxy Status
MX@www428.your-server.de10AutomaticDNS Only (Grey)

3. Configuring Auto-Discovery (SRV Records)

SRV (Service) records allow modern email clients (like Outlook or Thunderbird) to automatically detect the necessary server settings (IMAP, POP3, SMTP ports) when you simply type in your email address

These records generally point to mail.your-server.de and must be entered precisely. When creating these records in Cloudflare, you will typically use the “SRV” type and fill out five separate fields: Service, Protocol, Name, Target, and Priority/Weight/Port.

ServiceProtocolNamePriorityWeightPortTarget
_autodiscover_tcp@0100443mail.your-server.de
_imaps_tcp@0100993mail.your-server.de
_pop3s_tcp@00995mail.your-server.de
_submission_tcp@0100587mail.your-server.de
_imap_tcp@0100143mail.your-server.de

4. Setting Up Email Security (TXT Records)

These three TXT records are critical for email deliverability. They prevent spam and domain spoofing by verifying that emails coming from your domain are legitimate.

4.1. Sender Policy Framework (SPF)

This record specifies which servers (Hetzner’s in this case) are allowed to send mail for your domain.

TypeNameContent (Value)
TXT@“v=spf1 +a +mx ?all”

4.2. DomainKeys Identified Mail (DKIM)

DKIM uses a cryptographic key to sign your emails, proving they haven’t been tampered with. This long key must be copied exactly as provided by Hetzner. Note that the long string may be displayed in quotes and concatenated (joined together) in your DNS manager.

TypeNameContent (Value)
TXTdefault2504._domainkey“v=DKIM1; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2OjmPDfajT3a+N1Wm6YM” “G3oeL0wpNhqMG4q7xMzxKtC9xmQp49yTVZ99T5bXn0DoUDYF1vyx2UI3fg5oCOB1bVMrrGB8VbXX” “phDohnKwPlxiB8ItFfdxUyLcGhMiw4IznpV2iJBGxZLb0lH6ClJyWRkElhz41rfcLCpykkuJ6mfa” “AtlcglfpJxxSr+Bw+T/nXc1/LGMMK6Ghg9SBSN6Vu20s9w7nL0/ncKxlCurPI8B9V9DzD+IAT+bn” “ztxm20wbkKrCWvVg3XMjWOMbPxVV76+xaEYA4edWhX/0E8ot/2cYXptd9l2ZPvy7zc/9hoSAoz/U” “zi+J2q214fK/p6ecQIDAQAB”

4.3. Domain-based Message Authentication (DMARC)

DMARC tells receiving mail servers what to do if an email fails the SPF or DKIM checks. The p=reject policy in your record is a strong policy that tells servers to reject suspicious emails.

TypeNameContent (Value)
TXT_dmarc“v=DMARC1;p=reject;sp=none;pct=50;adkim=r;aspf=r;”

5. Final Step: Propagation and Testing

Once you’ve entered all nine records (1 MX, 5 SRV, 3 TXT) into your Cloudflare DNS manager and ensured they are all set to DNS Only, you need to wait for DNS propagation. This usually takes minutes but can sometimes take up to an hour or two.

You can verify your setup using an online tool like mxtoolbox.com to check the MX and SPF records. Once those pass, your Hetzner email should be fully functional using your high-speed external DNS!