I have recently switched our mail server to a new location by updating the appropriate DNS MX records in the domain. Everythings seems to work and I am getting the email on the new server already.

However, some applications on a web server that is using sendmail to send messages, are still sending messages to the old server. I assume there is either a cache meachanism in sendmail that "remembers" the old MX server or some sort of DNS cache in place (no dnsmasq or nscd installed).

How do I make the web server's sendmail use the new MX server?

Ubuntu 12.10

  • 2
    what if you log into that webserver and run dig mx domain.com from there. Does that show the correct record? – Halfgaar Feb 4 '14 at 13:19
  • yes, the correct server is listed in the answers section when running dig – Roman Semko Feb 4 '14 at 14:44
  • What is the TTL of the MX record, BTW? – Halfgaar Feb 4 '14 at 14:53
  • What WAS the TTL of the MX records? Have you checked that new records are propagated to ALL secondary DNS servers of the DNS domain? – AnFi Feb 5 '14 at 13:29

This requires more information. Sendmail doesn't cache DNS information, the DNS-client caches information, but not always. For example, Ubuntu doesn't cache DNS records by default (since 2011).

If your MX records are updated on your Name Server, then you need to flush the cache on your web server in order for it to query your Name Server for the new MX record; otherwise, the TTL value of your previous MX record will fix the issue on its own in 24-72 hours.

  1. Validate the MX record on the name server
  2. Clear cache from web server that has issue (dependent on your OS)

Confirm lookups on webserver by using dig (linux) or nslookup (winodws):

  • Thanks for your reply. Dig shows correct MX entry (I am on Ubuntu 12 as specified in the question). the problem persists for over a week now. :-/ – Roman Semko Feb 6 '14 at 5:34
  • Are you running dig on the web server? If you are and the DNS lookups are correct. Then you have your sendmail server hard-coded and it has nothing to do with cache. Check your sendmail installation on the web server and see if you have a smarthost configuration pointing to the wrong mail server. Check your /etc/mail/sendmail.mc for a section like "define(`SMART_HOST', <WrongMailServer>)dnl". If so, remove it and restart sendmail. If that doesn't pan out, then check your email headers to determine what mail servers they're using. – David George Feb 7 '14 at 17:58

Your Answer

