Mailserver and MX records in Cloudflare

Jorg Ancrath asked:

I built my own mail server using postfix/dovecot in CentOS 6, this is my postconf -n results:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
home_mailbox = Maildir/
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain =
myhostname =
mynetworks =,
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
relay_domains =
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550

I’ve tried using telnet to test my emails and I do get them in the /home/user/Maildir/new folder.

I assume everything is OK with the mail server, so I went ahead and added MX records to my DNS settings.

This is the first time I’ve used Cloudflare’s free DNS service, and I admit to not being the most knowledgeable person when it comes to this, but I added a couple of records in there:

  • MX – @ =>
  • A – => My VPS ip (where the mail server is located)

The MX record seems to be in place, a quick “dig MX” does wield a result. The problem now is… even though I created the record as, the actual entry as seen via dig is, a string seems to have been appended to the DNS record.

I’ve since tried sending email from an outside source (not telnet) without success. Do I need to reconfigure postfix and set myhostname as Am I missing something here in the grander scheme of DNS or is this just the way Cloudflare operates? Could my mailserver not be configured correctly? (logs from my telnet tests look fine)

My answer:

In the CloudFlare DNS settings, make sure that you have a “gray” cloud for the mail A record, in order for connections to that host to bypass CloudFlare and go to your mail server directly.

Beyond that, your DNS seems to be in a workable configuration, and you are (by your own admission) receiving mail successfully.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.