Pio's work related musings

Pio's work related musings

David  //  

Jun 30 / 6:12pm

Setting up wildcards with Exim4 and virtual domain

This is a quick howto for setting up Exim4 with:
1) several incoming (virtual) domains
2) some local users
3) wildcard catchall accounts to collect the emails not matching the local users
  • Setup the virtual domains in the dc_other_hostnames variable in /etc/exim4/update-exim4.conf.conf. These are the domains considered local by this installation of Exim4. Any other domains will be routed as remote mail either through the IP defined by dc_smarthost, or direct delivery through DNS lookup of the MX records, or a hubbed_hosts definition file if it exists which overrides the DNS lookups.
  • Create the local users with adduser
  • If required, create the local user sending addresses (for the From: header) in /etc/email-addresses (otherwise the local user will be stamped with the mail hostname defined in /etc/mailname)
  • Define the catchall accounts in a new a wildcard aliases file /etc/aliases_wildcards
    • # /etc/aliases_wildcards
    • #*@domain1.com: domain1-catchall-user
    • #*@domain2.net: domain1-catchall-user
  • Create a new router directive to process the wildcard aliases - the first 3 digits of the filename define which order routers are processed by Exim4. This needs to be after the local_user router which is by default 900 so any value higher than 900 will work. I've chosen 999. /etc/exim4/conf.d/router/999_exim4-config_system_aliases_wildcard
    • # This router handles wildcard aliasing using a /etc/aliases_wildcards file
    • # /etc/aliases_wildcards must exist as it is a non-standard file
    • system_aliases_wildcards:
    • debug_print = "R: system_aliases_wildcards for $local_part@$domain"
    • driver = redirect
    • domains = +local_domains
    • allow_fail
    • allow_defer
    • data = ${lookup{*@$domain}lsearch*{/etc/aliases_wildcards}}
    • file_transport = address_file
  • Check the routing works as expected
A good source of information on which config file does what in Exim4 can be found here
Filed under  //  exim