I currently have postfix and dovecot installed on my Ubuntu VPS. While I can log in via a mail client like thunderbird with the IP, it would be nice to have mail.example.com. I already own a domain with an MX record, so mail can be sent to my VPS, but how can I create the mail subdomain? I currently use cloudflare, so specific instructions for that would be appreciated. I'm good with Ubuntu and bash, but I suck at networking.

1 Answer 1


create a sub domain in you domain provider. if you domain is already pointed to IP by A record you can point C name with mail server IP (x.x.x.x)

mail.example.com x.x.x.x

Or else add a A record with mail server IP (x.x.x.x) and also add above cname

and setup webmail such as SquirrelMail https://www.tecmint.com/setup-postfix-mail-server-in-ubuntu-debian/

for clouldflare if you are using you own mx you can stay with that.



ps you will have to add cnames/A records by cloudflare dns if your dns is managed by cloudflare.

  • I did that, and dig and ping find my server ip when I test mail.example.com, but dovecot and postfix refuse to authenticate unless I use the direct IP Oct 9, 2017 at 1:32
  • in cloud flare bypass mx record to use direct ip and use Cname/A record in your domain settings control panel .. postfix may have difficulty with cloudflare shared ips if you use them as mx or A record. I think default cloudflare comes with mx bypass settings on. use A record with postfix that you have already set at domain provider
    – Aravinda
    Oct 9, 2017 at 1:49
  • Nevermind, a simple iPhone reboot resolved the domain issue. Oct 9, 2017 at 2:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.