At Exoweb, our software developers use bogus email addresses of the form *@example.com (where I mean “example.com” literally, not as an example) to test their software’s ability to send email. Since I don’t want our Postfix server to attempt to deliver these messages out on the Internet, I need Postfix to handle these messages and blackhole them (make them disappear, sent to
/dev/null). So what follows are instructions on how to blackhole an entire domain in Postfix.
First, we add a
virtual_alias_maps entry to
/etc/postfix/main.cf so that we can specify example.com as one of our virtual domains:
virtual_alias_maps = hash:/etc/postfix/virtual_alias
/etc/postfix/virtual_alias, add a catchall address:
We have to use blackhole@localhost here and not /dev/null/ because
virtual_alias_maps cannot run commands—it can only forward to real addresses. So we put an entry inside
/etc/aliases to handle the blackhole:
This assumes that one of your mydestination domains in
main.cf is localhost so that Postfix will actually consult the
In order to make these changes take affect, you have to rebuild the aliases database, build the virtual_alias database, and reload your Postfix configuration. Respectively:
# newaliases # postmap /etc/postfix/virtual_alias # postfix reload
Now, any emails you send to blackhole@localhost will disappear, and so will any emails addressed to email@example.com (provided they are relayed through your Postfix server).
Footnote: The top-level and second-level domain names that are reserved for testing can be found in RFC 2606.
2 thoughts on “How to send an entire domain to /dev/null in Postfix”
Just searched for Postfix Email Administrator in Edmonton. Need Help. I have poor Postfix skills. Please contact.
If you’re using Postfix newer than version 2.1, then you could do the same thing in the transport map using the DISCARD feature. This would save you from having to use the local transport, which, on mail gateways, may not be used. It would also only require one entry instead of two.