Discard mail with exim4 using :blackhole:Posted in Email Servers -
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. firstname.lastname@example.org) to /dev/null, you would add this to the /etc/alises file:
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 <= email@example.com H=mail-qk0-f179.google.com [220.127.116.11] P=esmtp S=3709 id=CAPP3RjhN1sy074zaqTHRD_P52fAN-=y4JCdavzSrQUF4bamz6A@mail.gmail.com 2015-12-15 15:36:14 1a8fTK-0003ip-Lp == /dev/null <firstname.lastname@example.org> 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:
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 <= email@example.com H=mail-qk0-f179.google.com [18.104.22.168] P=esmtp S=3702 id=CAPP3RjiqYfwhkBZREBWSqwtjUxELsv4JTq2kBFDpT2yQqVgk7Q@mail.gmail.com 2015-12-15 15:39:27 1a8fWR-0003jO-M3 => :blackhole: <firstname.lastname@example.org> 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.