i'm going a bit crazy over this one. so someone might help me clear out my doubts.

in my company i have set up two emailservers.

mx1.example.com (on-site) mx2.example.com (remote vps)

both with postfix and dovecot. PTR/rDNS records and static IP.

configured exactly the same.

mx1 works perfectly. but some emails go to mx2 for whatever reason.

we have to have every email on time for our business. i know that SPAM goes to mx2, most of the times. even though mx2 has the same spam-policy like mx1. some of our customers emails do as well which is unwanted.but unfortunately i haven't found out why yet.

my DNS records:

record type host value ttl priority

A mx1 xxx.xxx.xxx.xx1 automatic A mx2 xxx.xxx.xxx.xx2 automatic

CNAME mail mx1.example.com automatic

MX @ mx1.example.com 1 min 10 MX @ mx2.example.com 1 min 20

basically i want our emailclient (outlook 2010) to connect to mx2 whenever mx1 isn't reachable.because i suppose that mx2 will receive all emails when mx1 isn't reachable. i don't want mx2 to store all emails and deliver to mx1 when back online.

when i add the record: CNAME mail mx2.example.com automatic

and check my DNS from viewdns.info for example. my mailservers keep changing from mx1 to mx2 and viceversa all the time. and we virtually don't receive any emails. until i cmd -> ipconfig /flushdns and restart outlook on the clients. but then all emails get duplicated. another problem is that whenever mx1 goes down, out look sometimes seems to connect to mx2, but doesn't receive any emails due to the the selfsigned ssl certificate, which is exactly the same as on mx1 and already accepted and installed.

i also tried putting both mx to the same priority, but it's not really what i want. i don't need loadbalancing / roundrobin. since it seems, that emailclient doesn't connect to mx1 and after mx2 in order to collect all emails.

what i want is: if mx1 is down, all mail goes to mx2. and our emailclient connects to mx2 as well. is that possible somehow?

thx in advance for any help! regards, JOE

EDIT: maybe with 2 A-records pointing to xxx.xxx.xxx.xx1 and xxx.xxx.xxx.xx2 but as host mx1???

  • ok, thx for your answers. it's just that we really need this mailserver mx1 highly available, but sometimes i have to do updates/upgrades and i can't do that every night. i will try to schedule this as best as i can. on the other hand i have now found this tutorial: howtoforge.com/postfix_backup_mx - do you think this would be a valid solution? – Joe Silencio Oct 23 '16 at 20:12
  • Sure, that's precisely what I describe in my answer. – EEAA Oct 23 '16 at 20:52
  • Also, you may consider that you're not in a good place to host your own email if 1) you have to ask this type of question and 2) have very high uptime requirements. – EEAA Oct 23 '16 at 20:53
  • Well,unfortunately in the past we tried many different ISPs and weren't too satisfied with th results.so i was "forced" to host my own mailserver. I had a third party mailserver as fallback until i had my servers up and running in a good configuration.thx again for your advise – Joe Silencio Oct 23 '16 at 21:12
  • ISPs are notoriously horrible at hosting email, as it's not a primary competence for them. Google (GSuite), Microsoft (Office365), and Fastmail are all very viable and cost-effective solutions. All three of them will be able to host email with orders of magnitude more reliability than you'll be able to achieve short of spending huge amounts of money on infrastructure. – EEAA Oct 23 '16 at 21:17

You're doing things all wrong I'm afraid. Your backup MXes should be store-and-forward only. Clients should not be connecting to that server, ever. MXes are for highly-available mail delivery not serving mail clients. Configure your backup MX to deliver mail to your primary and your issue goes away.

As you've discovered, many MTAs don't respect MX priority. There's precious little you can do about that other than ensuring that mail delivery happens properly wherever mail lands.

As for providing a highly-available mailbox server for your clients, that's a completely different ball of wax, and needs to be considered as a separate goal from your MX issues.


I've never been a fan of the idea of a backup MX for several reasons, yours being chief among them.

Additionally, section of RFC 5321 makes a backup MX completely unnecessary. - https://tools.ietf.org/html/rfc5321#section-

  • 1
    I agree with this answer. @Joe, Maintaining backup mail servers is a pain in the ass, even if only for the reason of fighting spam. Spammers love backup mail servers. Think of better ways, such as making your mail server highly available if this is not enough for you: The sender MUST delay retrying a particular destination after one attempt has failed. – Daniel Oct 23 '16 at 19:39

the solution was to have a load balancer like haproxy in front, may be even with a floating ip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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