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 firstname.lastname@example.org (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.