I just set up my first ever email server and I’m proud of myself! 😊 Do you have any advice to avoid common problems? I mean something beginners often do that they shouldn’t. Thanks!
Congratulations! A mail server is quite demanding in terms of initial setup, but it’s also very rewarding !
Here are a few pointers I can give you:
- Using a good domain is important, some provider block entire TLDs for cheap domains (eg. .tk or .pw). I learnt it the hard way…
- Set your MX records to A records, not CNAME
- Ensure your PTR records match your A records for the mail server
- Learn about SPF and DKIM
- Set them up, and verify with mxtoolbox
- Use the
ip4:<ipv4>
and/orip6:<ipv6>
selectors for SPF - Setup a spamfilter (I like spamassassin)
- Leave it all running for a few weeks/months
- Publish a DMARC policy on your DNS, and verify with mxtoolbox
This should limit a lot your likeliness to end up in spam folders (which is usually the hardest part about running your mail server)
What’s the reason for using IPs instead of domain names for SPF and MX?
Because it’s the simplest form of mechanism for SPF, and the most understandable in my opinion.
a
andmx
mechanisms are justip4
/ip6
with extra resolving steps and more complex rules. For a selfhosted setup where you only have a single IP address, this is the most straightforwardAs an example, try to guess which one of these SPF records will or will not pass SPF, given that the IP address sending emails is 1.2.3.1:
$ORIGIN domain.tld. $TTL 1d @ SOA pluto.domain.tld. admin.domain.tld ([…]) NS pluto.domain.tld. NS saturn.domain.tld. MX 10 mx.domain.tld. A 1.2.3.5 TXT "v=spf1 a -all" TXT "v=spf1 mx -all" TXT "v=spf1 ip4:1.2.3.1 -all" jupiter A 1.2.3.1 pluto A 1.2.3.2 saturn A 1.2.3.3 venus A 1.2.3.4 mx CNAME jupiter.domain.tld.