How to Redirect Localhost Mail? – “remote host address is the local host” (exim)

aliaseseximmail-forwardingubuntu-14.04

I've just setup a VPS using VestaCP on Ubuntu 14.04, and am using the default exim mail server.

I would like to be able to forward mail to root@ onto another email address. But I'm getting a ton, and I mean a heap, of these error messages in my log:

2015-02-12 02:08:02 H=(mail.onlythebible.com) [106.187.53.43] sender verify defer for <root@mail.onlythebible.com>: remote host address is the local host

I'm actually a little confused (excuse my ignorance) is root@mail.onlythebible.com (my mail server) the same as root@localhost? Why would emails be sent there?

The command: exim -bt root@localhost returns the following:

LOG: MAIN
  remote host address is the local host: localhost (while routing <root@localhost>)
root@localhost cannot be resolved at this time: remote host address is the local host

I've tried aliases, ~/.forward, and few other things on google, but so far no luck.

Any suggestions?

Best Answer

Exim needs to be told which domains it will accept email for, typically in a domain list setting early in the config file. There are two general ways that it's done: 1. a static list of domain names 2. a lookup in a local file or from a database

As an example, in some previous systems that I managed it performed a sql lookup based on the domain of the envelope sender. Since it's a database lookup, it performs the lookup as it's needed, not "create a list when exim starts". Here is how it looks:

domainlist local_domains = @ : localhost : LOCAL_HOST_NAME : \
  ${lookup mysql {SELECT d.name \
  FROM  domain AS d \
  JOIN  user AS u ON d.user_id=u.id \
  JOIN  website AS w on u.id=w.user_id \
  WHERE d.name="${quote_mysql:${domain}}" AND \
        d.active=1 AND \
        w.status_id <= 4 AND \
        w.active=1 \
  LIMIT 1}}

In the above, LOCAL_HOST_NAME is a macro defined which is set to the full hostname (aka Fully Qualified Domain Name aka FQDN) so cron jobs can send email to itself (or aliases). It could just as easily do a lookup against a file or be a static list of domains. You need to make sure that all domains are in this list, or able to be looked up by any query this list performs.