Using email w/ Heroku and CNAME

Viewed 5194

I am in the process of setting up MX records on a HEROKU hosted app and am running into issues.

I have two CNAME's setup:

@ myapp.herokuapp.com
www myapp.herokuapp.com

Site works fine as setup above. I am now trying to add email support by adding Google Apps MX records.

@ ASPMX.L.GOOGLE.COM.  MX 10 1800  

--as well as four other MX fall backs--

Google Apps is saying it can't read the MX records. Is this because they are conflicting with the @ CNAME record? If so, should I drop that and used the "Naked Domain" method (Setup three A records instead). Heroku makes it sounds like this method is highly discouraged vs CNAMEs for "@" non WWW.

Thanks for the help!

4 Answers

I found the best way to do this is to use Google Apps "Naked Domain" 301 Redirect Feature as described in https://support.google.com/a/answer/2518373?hl=en

1) Go to Admin Console - Domains - Change Naked Redirect

2) Redirect to WWW.your_domain.com

3) You will setup 4 A-Records in your DNS pointing your your_domain.com to

  • 216.239.32.21
  • 216.239.34.21
  • 216.239.36.21
  • 216.239.38.21

Now, when somebody points to your_domain.com they get 301 redirected to WWW.your_domain.com This, btw is the same way gooogle.com behaves (301 redirect to www.google.com)

HT: http://smallchou.com/post/41388058201/heroku-and-root-aka-apex-or-naked-domains

If your DNS provider supports ALIAS (Namecheap now does) you can easily get both email (MX, TXT records) and use the naked url (example.com, instead of www.example.com) with heroku.

Instead of choosing CNAME record type, pick ALIAS. Namecheap example of advanced DNS line would be like this:

(Type)            (Host)           (Value)                                (TTL)
ALIAS Record      @                heroku-weird-dns-target.herokudns.com  5 min

ALIAS will play along with both TXT and MX.

Related