Home / Discard mail with exim4 using :blackhole:

Discard mail with exim4 using :blackhole:

The most obvious way to discard mail to a particular alias with the exim4 mail server is to send it to /dev/null, but unless file_transport is set in the exim configuration it won’t work. You can use :blackhole: instead.

/etc/aliases with /dev/null

To route mail to a particular address (e.g. noreply@example.com) to /dev/null, you would add this to the /etc/alises file:

noreply: /dev/null

If file_transport isn’t configured, you’ll get error messages like this in the log:

2015-12-15 15:36:14 1a8fTK-0003ip-Lp DKIM: d=example-com.20150623.gappssmtp.com s=20150623 c=relaxed/relaxed a=rsa-sha256 [verification succeeded]
2015-12-15 15:36:14 1a8fTK-0003ip-Lp <= me@example.com H=mail-qk0-f179.google.com [209.85.220.179] P=esmtp S=3709 id=CAPP3RjhN1sy074zaqTHRD_P52fAN-=y4JCdavzSrQUF4bamz6A@mail.gmail.com
2015-12-15 15:36:14 1a8fTK-0003ip-Lp == /dev/null <noreply@example.com> R=system_aliases defer (-30): file_transport unset in system_aliases router

Although there’s an error, the mail isn’t bounced back to the sender immediately, and sits undelivered in the mail queue (and presumably will bounce back eventually).

Use :blackhole: instead

Without having to make any configuration changes to exim, you can instead route the mail to :blackhole: – change the line in /etc/alises to this:

noreply: :blackhole:

And then you’ll get this in your log file:

2015-12-15 15:39:27 1a8fWR-0003jO-M3 DKIM: d=example-com.20150623.gappssmtp.com s=20150623 c=relaxed/relaxed a=rsa-sha256 [verification succeeded]
2015-12-15 15:39:27 1a8fWR-0003jO-M3 <= me@example.com H=mail-qk0-f179.google.com [209.85.220.179] P=esmtp S=3702 id=CAPP3RjiqYfwhkBZREBWSqwtjUxELsv4JTq2kBFDpT2yQqVgk7Q@mail.gmail.com
2015-12-15 15:39:27 1a8fWR-0003jO-M3 => :blackhole: <noreply@example.com> R=system_aliases
2015-12-15 15:39:27 1a8fWR-0003jO-M3 Completed

The mail is now “delivered” and there are no errors in the log file.