Keeping your mail server out of the spam folder
Receiving providers judge mail by the reputation of the sending address and by a handful of DNS records. A dedicated server gives you full control over both.
Why does mail from a new server land in spam?
Mostly because the receiving side knows nothing good about the address yet, and any missing record tips the scale. Large mailbox providers score each message on the reputation of the sending IP and domain, the authentication results, the content and how recipients react. A fresh IPv4 address starts neutral, so the first weeks decide whether it becomes trusted. Getting every technical record right before the first message leaves is the part entirely in your hands.
Which DNS records does a sending server need?
Four records do almost all the work, and each one answers a different question for the receiver.
| Record | What it proves | Example value |
|---|---|---|
| PTR (reverse DNS) | The IP address belongs to a named host | mx1.example.net |
| SPF (TXT on the domain) | This IP may send for the domain | v=spf1 ip4:192.0.2.40 -all |
| DKIM (TXT on a selector) | The message was signed by the domain and not altered | s2026._domainkey public key |
DMARC (TXT on _dmarc) | What to do when SPF or DKIM fail, and where to report | v=DMARC1; p=quarantine; rua=mailto:dmarc@example.net |
The reverse DNS of your IPv4 address is set in our console, on the server page, and takes effect within minutes. Make it match the hostname your mail server announces in its greeting, and make that name resolve forward to the same address. This forward and reverse agreement is the first check many receivers run.
hostnamectl set-hostname mx1.example.net dig +short -x 192.0.2.40 dig +short mx1.example.net A
How do I sign outgoing mail with DKIM?
Generate a key pair, publish the public half in DNS, and let a signing filter add the header to each message. With Postfix the common choice is OpenDKIM; Exim and several mail suites can sign natively. A 2048-bit key is the safe size today. Rotate the selector name once a year so an old key can be retired cleanly.
apt install opendkim opendkim-tools opendkim-genkey -b 2048 -d example.net -s s2026 -D /etc/opendkim/keys/example.net cat /etc/opendkim/keys/example.net/s2026.txt
Paste the TXT value into your DNS zone, then send a test message to a mailbox you own and read the Authentication-Results header: you want dkim=pass, spf=pass and dmarc=pass all on one line.
How fast can a new address send?
Slowly at first. Start with mail people expect, such as receipts and password resets, and grow volume over two to four weeks. A sensible pattern is a few hundred messages a day in week one, doubling each week while bounce and complaint rates stay low. Configure per-domain concurrency in the mail server so one large provider never receives hundreds of connections at once.
postconf -e "smtp_destination_concurrency_limit = 4" postconf -e "smtp_destination_rate_delay = 1s" systemctl reload postfix
What hurts sender reputation most?
Sending to addresses that do not exist and to people who never asked for the mail. Remove hard bounces after the first failure, honour unsubscribes at once, and never import a purchased list. Watch the mail log for repeated 550 replies and deferrals that mention reputation or rate; they are early warnings worth acting on the same day.
- Keep complaint rates below one in a thousand messages.
- Add a visible one-click unsubscribe header to bulk mail.
- Separate transactional and marketing mail by subdomain, so a campaign never slows down password resets.
- Close open relay paths: only authenticated users and local applications may submit mail.
How do I check that the server is not an open relay?
Try to send from an outside address to another outside address through your server; it must refuse. In Postfix, the smtpd_relay_restrictions setting should end with reject_unauth_destination. A relay left open is found by spammers within hours and ruins the address reputation for everyone who uses it afterwards, so test it after every configuration change.
What about IPv6 and mail?
Every server includes an IPv6 block, and some receivers apply stricter rules to IPv6 senders. The console sets the reverse DNS of the IPv4 address, so the tidy choice is to deliver over IPv4 alone with inet_protocols = ipv4 in Postfix and keep IPv6 for web and other services. Our IPv6 and reverse DNS on your server article explains how the block is routed. For the sending side in general, including relays and local delivery for applications, see Send email from your server.
Related pages
Send email from your server
Let applications send mail reliably: a local Postfix that only sends, queue checks, port 25 versus submission and using an outside relay.
Read moreIPv6 and reverse DNS on your server
Configuring the IPv6 block that comes with every machine and setting the reverse DNS name of its IPv4 address from the console.
Read moreHardening a new dedicated server
The first hour on a fresh machine: SSH keys, a firewall, automatic updates, brute force blocking and a habit of checking what listens.
Read moreEssential servers
Affordable bare metal for websites, development and first production apps.
Read moreQuestions and answers
Where do I set reverse DNS for my server?
In the console, on the server page, under Reverse DNS. Use the same name that your mail server sends in its greeting and make sure that name resolves back to the IPv4 address.
Do I need SPF, DKIM and DMARC all together?
Yes for reliable delivery. SPF names the allowed sending addresses, DKIM signs each message and DMARC tells receivers how to treat failures and where to send reports.
How long does it take for a new IP to build reputation?
Plan two to four weeks of gradual growth, starting with mail recipients expect, while keeping bounce and complaint rates low.
Can I get a second IP address for marketing mail?
Each server comes with one IPv4 address and an IPv6 block, and extra IPv4 addresses are not sold. Separate mail streams by subdomain and DKIM selector instead, or run a second server.
How do I test my setup?
Send a message to a mailbox you own and read the Authentication-Results header. It should show pass for SPF, DKIM and DMARC.