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, and we are working with postfix.


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

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

$ nslookup mail.domain.tld

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

$ nslookup

Non-authoritative answer:     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.


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 ~all"

Final verification

  1. check rbl
  2. check your score on
  3. check you score by sending mail to