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
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)
- #/etc/email-addresses
- user1: user1@domain1.com
- user2: user2@domain2.net
- 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
- exim4 -bt user1@domain1.com
- exim4 -bt notauser@domain1.com
- The first command should show email routing to a local user using the local_user router.
- R: system_aliases for user1@domain1.com
- R: userforward for user1@domain1.com
- R: procmail for user1@domain1.com
- R: maildrop for user1@domain1.com
- R: lowuid_aliases for user1@domain1.com (UID 1001)
- R: local_user for user1@domain1.com
- user1@domain1.com
- router = local_user, transport = maildir_home
- The second command should show email routing to the catchall account again using the local_user router:
- R: system_aliases for notauser@domain1.com
- R: system_aliases_wildcards for notauser@domain1.com
- R: system_aliases for domain1-catchall-user@localsystem.com
- R: userforward for domain1-catchall-user@localsystem.com
- R: procmail for domain1-catchall-user@localsystem.com
- R: maildrop for domain1-catchall-user@localsystem.com
- R: lowuid_aliases for domain1-catchall-user@localsystem.com (UID 1000)
- R: local_user for domain1-catchall-user@localsystem.com
- domain1-catchall-user@localsystem.com
- router = local_user, transport = maildir_home
0 comments
Leave a comment...
To leave a comment on this posterous, please login by clicking one of the following.
