To block anyone (local (mail/sendmail command) system users and SMTP users) from sending to an email address you cannot rely on smtpd_recipient_restrictions
. You need to place the restriction into the qmgr
phase. For this I've found that transport_maps
works well.
main.cf
:
transport_maps = pcre:/etc/postfix/transport_maps
transport_maps
:
/^user(\+[^@]+)?@host\.com/ discard:
/.*/ :
Maybe there is a better solution but this one appears to work for all delivery types. FYI, that regex supports user@host.com
and user+anything@host.com
assuming a +
delimiter. It prevents To, CC and BCC.
Also make sure your postfix has pcre support enabled. On Debian based (Ubuntu, etc) operating systems that is provided by the postfix-pcre package.