Question

I've recently taken on a VPS (Ubuntu 12.04) to host a few websites (with domains) and have recently set up Postfix/Dovecot to act as a mail server for the sites as well. The name server records are pointing to my registrar's nameservers.

I have a few domains (domain1.com, domain2.com, domain3.com) with their A records pointing to the IP of my VPS, which I've set up with name based virtual-hosts for apache.

I imagined that once it was set up correctly, I would be able to enter mail.domain1.com as my pop3/imap/smtp mail server on an email client, along with my username and password. It would be fine for this to be the same for the other domains too.

Could someone tell me what the correct A and MX DNS records should be for this and how I should set my hostname on my vps and in settings for postfix/dovecot?

For instance I've set my vps hostname as domain1.com and I put the same in the postfix/dovecot config, but wondered if I should have put mail.domain1.com? Do I set CNAMEs for mail, imap, pop, smtp to point to an MX record or an A record so that the server can be reached at all of them?

Many thanks for any help you can offer :)

Was it helpful?

Solution

Let us assume that you are hosting mail servers for three domains domain1.com, domain2.com, domain3.com in your VPS that has the IP address 1.2.3.4.

  • POP3/IMAP/SMTP DNS records are used by your customers to send/receive mails by configuring their mail clients. So set the following A records.

    mail.domain1.com  A 1.2.3.4
    mail.domain2.com  A 1.2.3.4
    mail.domain3.com  A 1.2.3.4
    
  • To receive mails on the same server for all your domains, set the MX records for all the domains as follows.

    domain1.com MX mail.domain1.com
    domain2.com MX mail.domain2.com
    domain3.com MX mail.domain3.com
    
  • Your system name has nothing to do with the mail server setup.

Postfix setup:

since your postfix instance is gonna handle multiple domains, you can either set a whitelabelled myhostname for your postfix server like somedomain.tld or use one of mail.domain1.com, mail.domain2.com or mail.domain3.com. If you are planning to use mail.domain1.com as your mail server name(myhostname value in postfix) and your server has 1.2.3.4 IP and you are gonna handle mail for domain1.com, domain2.com, domain3.com , setting up all the following is always recommended.

  • A record of mail.domain1.com pointing to 1.2.3.4
  • PTR record for 1.2.3.4 pointing to mail.domain1.com
  • SPF record for domain1.com, domain2.com, domain3.com should include 1.2.3.4

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top