0

I have a domain, and that domain uses another one of my domains to handle mail. I'm having trouble getting it configured in a way to make all mail clients play well with my domains.

In terms of foo and bar, foo.com is my "main" server:

  • foo.com is my mail server
  • foo.com: MX record => IP Address
  • mail.foo.com: MX record => IP Address
  • mail.foo.com: A record => IP Address

And bar.com is my domain that uses foo.com:

  • bar.com: MX record => mail.foo.com
  • mail.bar.com: MX record => mail.foo.com

I cannot add the following for mail.bar.com:

  • mail.bar.com: CNAME record => mail.foo.com

When I attempt to enter the CNAME record so some mail clients can connect via mail.bar.com, I get an error:

Duplicate subdomains are not allowed between these record types: MX; CNAME

Essentially the error is saying I cannot have:

  • mail.bar.com: MX record => mail.foo.com
  • mail.bar.com: CNAME record => mail.foo.com

I don't quite understand the error messages because the resource records specify different services. Folks trying to send email to the domains will use the MX records; while folks trying to retrieve their email will use the CNAME record.

I looked at RFC 1035, but I do not see where the standard prohibits the combination. I also tried to follow some of the updated RFCs, but many of them did not apply to the base service implementation.

Are MX and CNAME mutually exclusive? If so, is there a reference somewhere?


Here's the related question: Can't configure account with Thunderbird (broken Mail Account Setup). Thunderbird refuses to allow me to create an account. I'm trying to tweak DNS by adding a CNAME to see if it helps.

  • 1
    Couldn't you use an ALIAS record instead of a CNAME for the second mail.bar.com? I was under the impression that CNAME should only be used when there are no other existing records under that name. – JNevill Sep 17 '14 at 15:43
  • @JNevill - this is not web mail, so URL aliases won't be helpful. The server only offers SMTP, SMTPS, IMAPS and Secure-MSA. – jww Sep 17 '14 at 16:02
  • @JNevill - Re: "[use CNAME when] ... no other existing records". Yea, that worked for most clients. I added information on the underlying problem. – jww Sep 17 '14 at 16:10
2

Are MX and CNAME mutually exclusive? If so, is there a reference somewhere?

A CNAME record maps a name to another name. It should only be used when there are no other records for that name (MX, A, etc.). (RFC 1034 section 3.6.2, RFC 1912 section 2.4).

From RFC 1912 s. 2.4:

A CNAME record is not allowed to coexist with any other data. In other words, if suzy.podunk.xx is an alias for sue.podunk.xx, you can't also have an MX record for suzy.podunk.edu, or an A record, or even a TXT record

  • A CNAME is an alias. Also, this is not web mail, so URL aliases won't be helpful. The server only offers SMTP, SMTPS, IMAPS and Secure-MSA. – jww Sep 17 '14 at 15:58
  • True, I was forgetting something in there. ;) Anyhow, I've edited the answer to more directly answer your posed question. – Ƭᴇcʜιᴇ007 Sep 17 '14 at 16:51
  • Perfect, thanks. Would you mind taking a quick look at Can't configure account with Thunderbird (broken Mail Account Setup). Its the reason I'm trying to add this additional record. Outlook, Apple Mail, Microsoft Mail are all OK. Thunderbird is the problem child. – jww Sep 17 '14 at 16:58
1

This is rather twisted up. Let's un-twist it.

First, your mail server should not be called foo.com, you are almost certainly going to want the A record attached to that to go to your web server, not your mail server. And that's okay since you setup user@foo.com email addresses using MX records, that's what they are for.

I'm going to assume you will call and configure your mail server to know itself as mail.foo.com, i.e., that will be it's fully-qualified host name. You can then configure it as the final destination for mail going to user@foo.com and also to source email (senders) using that same domain. Later on, you can also configure it to be the final destination for user@bar.com mail, but hold that though for now.

So what you need in DNS for this so far is:

foo.com.   IN MX  10 mail.foo.com.
mail.foo.com.  IN A  12.12.12.12

(replace 12.12.12.12 with the real IP address of your mail server, of course)

You'll also need to arrange to have your hosting provider put in a PTR record (reverse-mapping entry) that reverse-maps 12.12.12.12 to the name of your mail server (mail.foo.com).

And that's all you need in DNS for mail to work.

If you now want to have your mail server accept mail for user@bar.com. all you have to do is add another MX record attached to the bar.com domain sending mail to your mail server, like this:

bar.com.   IN MX  10 mail.foo.com.

And then, of course, configure your mailer to be final destination for bar.com mail.

Simple as that. This leaves the A records attached to foo.com and bar.com available to point to web servers.

The last step is to add Sender Policy (SPF) records so you can indicate who the authorized sending mailers (MTAs) are for both of these domains. You'd add TXT records like this:

foo.com.  IN TXT  "v=spf1 mx -all"
bar.com.  IN TXT  "v=spf1 mx -all"

You can go further and setup / configure DKIM as well, but that involves keys and signing so it's a bit more involved. Google is your friend for that.

Hope that helps.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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