{{tag>mail exim4}} ====== Configure exim4 to bypass local mail delivery ====== If you will be receiving email via Google mail and have a custom domain registered with them e.g. yourdomain.com, but that domain is also pointing to your server then you need to setup a hubbed host on your server to properly receive mail sent from your server at smth@yourdomain.com. The server (exim) needs to know that "smth" is not a user on the server but a email inbox at Google. ===== Make sure the router exists first ===== cat /etc/exim4/conf.d/router/150_exim4-config_hubbed_hosts # router/150_exim4-config_hubbed_hosts ################################# # route specific domains manually. # # see exim4-config_files(5) and spec.txt chapter 20.3 through 20.7 for # more detailed documentation. hubbed_hosts: debug_print = "R: hubbed_hosts for $domain" driver = manualroute domains = "${if exists{CONFDIR/hubbed_hosts}\ {partial-lsearch;CONFDIR/hubbed_hosts}\ fail}" same_domain_copy_routing = yes route_data = ${lookup{$domain}partial-lsearch{CONFDIR/hubbed_hosts}} transport = remote_smtp ===== Create hubbed_hosts file ===== vi /etc/exim4/hubbed_hosts It should contain this: yourdomain.com: mx.external.com:aspmx.l.google.com ===== Then restart exim: ===== systemctl restart exim4 ===== Check the mail routing on the server ===== Before: root@yourdomain # exim -bt smth@yourdomain.com R: system_aliases for smth@yourdomain.com smth@yourdomain.com is undeliverable: Unrouteable address After: root@yourdomain # exim -bt smth@yourdomain.com R: hubbed_hosts for yourdomain.com smth@yourdomain.com router = hubbed_hosts, transport = remote_smtp host aspmx.l.google.com [2a00:1450:400c:c0b::1b] host aspmx.l.google.com [74.125.140.27] host alt1.aspmx.l.google.com [2a00:1450:4010:c0f::1b] host alt1.aspmx.l.google.com [108.177.14.27] host alt2.aspmx.l.google.com [2404:6800:4003:c00::1a] host alt2.aspmx.l.google.com [74.125.200.27] host aspmx2.googlemail.com [2a00:1450:4010:c0f::1a] host aspmx2.googlemail.com [108.177.14.27] host aspmx3.googlemail.com [2404:6800:4003:c00::1b] host aspmx3.googlemail.com [74.125.200.26] ====== Tested on ====== * Debian 9 ====== References ====== * manual: man exim4-config_files * http://www.yann.com/en/configure-exim4-to-bypass-local-delivery-on-web-server-17/04/2014.html