I have just installed exim4, and my /etc/hosts file looks like this:
127.0.0.1 localhost
127.0.1.1 mycomputer
192.168.100.5 rpi.mydomain.com
However, when I run exim -bt john@rpi.mydomain.com to test deliverability, it says:
R: dnslookup for john@rpi.mydomain.com
john@rpi.mydomain.com is undeliverable
It appears that Exim is not using the entries in /etc/hosts to resolve domain name. To fix the problem, I added this to /etc/exim4/conf.d/router/200_exim4-config_primary before all other router entries:
mycustomlookup:
debug_print = "R: mycustomlookup for $local_part@$domain"
driver = manualroute
transport = remote_smtp
route_list=rpi.mydomain.com 192.168.100.5
Problem solved. exim -bt john@rpi.mydomain.com:
R: mycustomlookup for john@rpi.mydomain.com
user@rpi.mydomain.com
router = mycustomlookup, transport = remote_smtp
host 192.168.100.5 [192.168.100.5]
The problem now is that I don't want to have to manually edit the Exim configuration every time I change the entries in /etc/hosts. Is there a way to make Exim use /etc/hosts to resolve domain names?