Setting up own mail server

This post describes all the things you will have to do, after (or before) installing and configuring your mail server, because that is where it all starts. Without it, you might have problems sending mail, because remote domains might think your server sends spam or is not delegated to send emails for your domain…

For simplicity, our mail server hostname is mail.domain.tld on ip 1.1.1.1, and we are working with postfix.

EHLO/HELO host

Mail server should always use its mail hostname when communicating with outer world.

smtp_helo_name = mail.domain.tld

DNS record

Mail server should have an A record in your domain zone. This is needed only in domain that will handle mails.

mail    IN  A 1.1.1.1

Reverse address for ip 1.1.1.1 should point back to mail.domain.tld.

$ nslookup mail.domain.tld
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   mail.domain.tld
Address: 1.1.1.1

$ nslookup 1.1.1.1
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
1.1.1.1.in-addr.arpa     name = mail.domain.tld.

MX record

Setup which server(s) will be responsible for processing mail, for current domain.

@       IN   MX 10 mail.domain.tld.

You can specify multiple servers, with different priorities.

SPF

Lets restrict which server are allowed to send emails on behalf of current domain.

This will allows all server, that are specified in MX section:

@       IN      TXT     "v=spf1 mx ~all"

And this will additionally allow Google’s Gmail to send mails for us:

@       IN      TXT     "v=spf1 mx include:_spf.google.com ~all"

Final verification

  1. check rbl http://multirbl.valli.org/
  2. check your score on https://www.mail-tester.com
  3. check you score by sending mail to check-auth@verifier.port25.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*