How to set up hosting on Heroku and email forwarders on a WHM (cPanel)?

silvenon asked:

I’m using DNSimple for managing my records, hosting my site at Heroku and I want to use a Linux WHM (cPanel) for managing emails forwarding.

Hosting works, but I’m having a hard time getting emails to work. Here are my (pseudo-)records:

Type    Name                TTL    Points to
---------------------------------------------------------
ALIAS | mydomain.com      | 3600 | mydomain.herokuapp.com
CNAME | www.mydomain.com  | 3600 | mydomain.herokuapp.com
CNAME | mail.mydomain.com | 600  | <WHM server IP address>
MX    | mydomain.com      | 600  | <WHM server IP address>
NS    | mydomain.com      | 3600 | ns1.dnsimple.com
...   | ...               | ...  | ...
NS    | mydomain.com      | 3600 | ns4.dnsimple.com

There are two more records, SOA and TXT, generated by DNSimple, but I don’t think those are relevant. When I add an A-record:

A | mydomain.com | 3600 | WHM server IP address

and change the mail CNAME and MX records to mydomain.com, emails start working, but then the hosting doesn’t work anymore.

Is this possible to achieve?

My answer:


You used a CNAME for the naked domain, which overrides any other record. I’m quite surprised DNSimple actually accepted this, since it’s not really a workable configuration.

The naked domain should point to a server which does nothing but send a 301 redirect to www. which is pointed at Heroku.

See Why does Heroku warn against “naked” domain names? for the reasons why this situation exists.


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.