Debian 6 (squeeze), Exim4 and Catch-All

I recently had to set up a system to receive e-mail destined for a given domain… all of it…

This seemed like a straight forward operation overall.  Set up a server, configure it and then… hrm… and then what.  How was I going to get all the e-mail to go into a mailbox on the system rather than just get bounced around or force the creation of an account for every single address I wanted to receive on.  Well, it took some searching but I finally found the exact details so I thought I'd post them here as well.

It should be noted that I accomplished this with a split configuration.  If you don't have one, this may still work but you'll have to hunt for where to put the directive.  If you can reconfigure what you have to a split configuration use the dpkg-reconfigure exim4-config command to run through the initial configuration options again and choose a split configuration at the end.

First, make 'sure' that your /etc/exim4/update-exim4.conf.conf file has all the correct entries in it.  If you don't have those correct, you won't be receiving much of anything.  Below is a sample of the configuration I used:

dc_local_interfaces=' ; ::1 ; MYIPADDRESS'

Next, make sure you have a user account (or create one) where you would like all the e-mail to be delivered to.  Alternatively, you 'can' route all of the e-mail to another valid e-mail address should you choose to do that.  To create an account on Debian use adduser USERNAME and you'll be prompted for some basic information.

If you created a user in the previous step, you will now need to edit your /etc/aliases file so it is something similiar to what is below:

# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root


Now, create a file 950_exim4-config_catch_all in the /etc/exim4/conf.d/router/ directory with the following information in it:

   debug_print = "R: catch_all for $local_part@$domain"
   driver = redirect
   data = ${lookup{*}lsearch{/etc/aliases}}

This will tell exim to deliver ALL mail sent to your specified domain to the catchall account in etc/aliases.  Now, alternatively, if you're wanting to re-direct these messages to another valid e-mail address you can use the following entry here (and also make sure you skip creating user accounts and all that sort of thing):

   debug_print = "R: catch_all for $local_part@$domain"
   driver = redirect
   domains = MYDOMAIN.com
   data = [email protected]

And that should do it.  Send exim a reload by /etc/init.d/exim4 reload and you should start seeing messages go where you're wanting them to.  You can monitor /var/log/exim4/mainlog to get a better picture of what's happening to the messages and to troubleshoot any problems.

Torry Crass

Leave a Comment