touch /etc/postfix/blocked
)/etc/postfix/main.cf
and append the virtual_alias_maps
with pcre:/etc/postfix/blocked
. Your end result should look like
...
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf,mysql:/etc/postfix/mysql-email2email.cf,pcre:/etc/postfix/blocked
...
/etc/postfix/blocked
and add the local address for which you want to discard incoming mails appended with <tab>discard:
. It should look likeyourlocaladdressyouwantedtohaveblocked@yourdomain.com discard:
tail -f /var/log/mail.log
). NOQUEUE: reject: RCPT from mail-am6eur05on2060.outbound.protection.outlook.com[40.107.22.60]: 451 4.3.0 <yourlocaladdressyouwantedtohaveblocked@yourdomain.com>: Temporary lookup failure; from=<yourexternalmail@mailservice.com> to=<yourlocaladdressyouwantedtohaveblocked@yourdomain.com>> proto=ESMTP helo=<EUR05-AM6-obe.outbound.protection.outlook.com>
You can change the named of the "blocked" file with anything you want, as long as you use the same filename in main.cf when appending virtual_alias_maps
.
More PCRE information can be found at https://www.postfix.org/PCRE_README.html
Since PCRE is regex you can add patterns to discard instead of full addresses if you wish. More information at https://serverfault.com/a/1045056/277567