I have some websites on AWS (Windows Server 2012 R2), and I'm trying setup a mail server. I have installed hMailServer, and in the guide say I need configure the DNS records for mail. I never needed setup email server from zero like now, then I'm a bit confused about the DNS records needed for this.

I read in some guide I will need A, MX and PTR records for this. Currently, my registar has only this records:

mydomain.com A 1.2.3.4  
www.mydomain.com A 1.2.3.4

Now, I think I will need create that records:

mail.mydomain.com A 1.2.3.4
mail.mydomain.com MX 10 mail.mydomain.com

My questions:

  1. Am I doing correctly?
  2. What about the PTR record? I needed?
  3. I will/can use this "mail.mydomain.com" like above in SMTP, POP and IMAP? Or I will need create different DNS records for this?
  4. How can I do/know if I did correctly? I was using mxtoolbox, but even there I dont understand if I need inform "mydomain.com" or "mail.mydomain.com" on the tests.

Solution 1:

When other people will write to [email protected], all SMTP servers in the world will search for the relevant server(s) handling emails for @mydomain.com. For that, they will check the DNS for MX records on mydomain.com, or A/AAAA records if MX records are not found.

MX records will give a priority and an hostname. That hostname can be anything you like (mail.$DOMAIN may be often used but is absolutely not mandatory), even in another domain name (and especially if your email setup is outsourced to a third party).

This is for the outside emails you receive. For POP/IMAP (BTW: nowadays you should skip providing POP altogether, and only provide IMAP over TLS) you should define on which server are the emails stored and where your POP/IMAP daemons will run. This may be the same server as the one on the MX record or another server if you have a complicated email setup. In all cases you could define a DNS record (even a CNAME) for imap.mydomain.com to give to your users (this would make it easier to change it later if you need).

The PTR record comes into play (in some sort) only if your SMTP server do also send emails outside. In such cases, you will need to contact the owner of the IP blocks (v4 and v6) in which your SMTP server has an IP address. It could be your ISP or your hosting company. They will let you know how to setup the PTR record.