Exim4 and routing message to /dev/null

Fairly common practice from Sendmail and even Postfix setups is to use an alias in /etc/aliases or some such file to route mail for a certain address to the “bitbucket.” Like this:

spamtrap: /dev/null

Well, put that into /etc/aliases on a Debian system running Exim4 with a stock config and it won’t work. I learned from a post to the Pkg-exim4-users list what config change should allow this to work. Then I saw the bug they’d found. Then I came up with a better way around that bug – I think.

Now, there’s a bit of going around your elbow to get to you ankle with configuring exim4 on Debian – probably so that autoupdates with the package system works well…

Start in /etc/exim4
A stock config will ignore what’s in conf.d and subdirs. It will build a config file from exim4.conf.template and update-exim4.conf.conf and put the result in /var/lib/exim4/config.autogenerated.

Edit exim4.conf.template and find this set of lines:

group = SYSTEM_ALIASES_GROUP
.endif
.ifdef SYSTEM_ALIASES_FILE_TRANSPORT
file_transport = SYSTEM_ALIASES_FILE_TRANSPORT
.endif
.ifdef SYSTEM_ALIASES_PIPE_TRANSPORT
pipe_transport = SYSTEM_ALIASES_PIPE_TRANSPORT

and change it to this:

group = SYSTEM_ALIASES_GROUP
.endif
#.ifdef SYSTEM_ALIASES_FILE_TRANSPORT
#file_transport = SYSTEM_ALIASES_FILE_TRANSPORT
#.endif
file_transport = address_file
.ifdef SYSTEM_ALIASES_PIPE_TRANSPORT
pipe_transport = SYSTEM_ALIASES_PIPE_TRANSPORT

Then run “update_exim4.conf” and restart or at least reload exim4 with “/etc/init.d/exim4 restart”

Turns out that the macro processor which assembles the config files from templates doesn’t handle names > 24 characters in length and so, what you intend setting in SYSTEM_ALIASES_FILE_TRANSPORT never gets set. So, just do it staticly and remember it.

Should you ever need to switch to the conf.d/{subdirs} mode of managing your config files – make a similar change in conf.d/router/400_exim4-config_system_aliases and you’ll be fine.

Leave a Reply

You must be logged in to post a comment.