Apr 24

Exim4: "temporarily rejected RCPT" problem solved

Category: Linux   — Published by goeszen on April 24, 2012 at 2:10 pm

If you, like me, get many "temporarily rejected RCPT <mail@example.com>: remote host address is the local host" messages in exim's /var/log/exim4/mainlog log, then here's what I found out to be the solution.

  • So you've freshly installed exim or got a fresh install with Debian Squeeze?
  • You did not tinker with the config files manually but used dpkg-reconfigure exim4-config so that you were guided through the basic config?
  • You are not running greylistd, although all the other posts you've found related to "temporarily rejected RCPT" are related to that? (Note that exim4 has greylisting not built in or installed with it by default! So the error here is not coming from there.)
  • No mail is getting into your server, you are not receiving mail in your inbox.

My solution:
Check your FQDN (fully qualified domain name), the value you filled in during the pkg-reconfigure wizard on the first reconfigure question seems to be wrong!
- So, step number one: use hostname --fqdn to get the actual, real FQDN of your machine. If that doesn't return what you expected, go and read the next paragraph on how to change your FQDN.
- Step two: After that restart the reconfigure and answer all the questions as before, this time check the fqdn setting.
- Step three: restart exim, for example with /etc/init.d/exim4 restart - and after that mail should work. Other SMTP hosts will retry delivery on previously rejected mail so wait a bit.

In case you need to change your FQDN:
Sometimes a machine isn't returning the right FQDN hostname. To fix that, open /etc/hosts and fill in your hostname (subdomain) and domain name:       .localdomain         localhost       mail.example.com          mail

::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
# --- BEGIN PVE ---     mail.example.com          mail
# --- END PVE ---

"mail" is the host name / subdomain here. Then open another file, open /etc/hostname and make sure the name of your host is in there. (It's usually the only text in this file). In our example case here, the word "mail". After that, run

hostname -F /etc/hostname

which is a command that's normally issued on bootup and we issue it manually here.
Also make sure that wherever you registered your domain (your domain provider), in settings, an MX record has to point at this domain.


(In a debug session [see below: Coda point 2 for that] I found out that exim reported "451 Temporary local problem - please try later" to calling SMTP servers, so my local config seemed to be the problem, and as the errors also mentioned something with local host name as the root of the problem, I figured it had to do with my FQDN setting.)

Some posts say that this is related to DNS - it is not, not really. I had no hints of failed DNS lookups in the logs.

Watch what exim is doing, the easy way with:
$ tail /var/log/exim4/mainlog -f

This post here was useful:
use exim -d -bh [a-senders-ip-address] with an IP from the logs where you've found the error with exim in a debug session.
Manually enter a MAIL FROM: foo@example.com and exim will tell you how it handles it.
Then manually enter a receiver address with RCPT TO: my-email@example.com, where in my case exim began to point me into the right direction.

Leave a Reply