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 |      | 3600 |
CNAME |  | 3600 |
CNAME | | 600  | <WHM server IP address>
MX    |      | 600  | <WHM server IP address>
NS    |      | 3600 |
...   | ...               | ...  | ...
NS    |      | 3600 |

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 | | 3600 | WHM server IP address

and change the mail CNAME and MX records to, 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.