How to discard mails sent from a specific local user to external addresses?

To do what OP need, we need a check at transport level, which turn out to be simple.

  1. Add following line to /etc/postfix/

    sender_dependent_default_transport_maps = hash:/etc/postfix/sender_transport_maps
  2. Create /etc/postfix/sender_transport_maps as follow

    [email protected]   discard
  3. Create postfix map file and restart postfix

    cd /etc/postfix
    postmap sender_transport_maps
    service postfix restart

This method works because postfix only use transport map for out-bound mail. In this case, instead of using a normal smtp service (smtp:), we use postfix DISCARD service.

The sender_dependent_default_transport_maps didn't work at all for me. Even with smtpd -vv in to increase debug didn't help let me know why it didn't work (possibly an old postfix version).

Instead I used

smtpd_sender_restrictions = check_sender_access  pcre:/etc/postfix/sender_domains, discard

with the sender_domains file containing

/[email protected]/  DISCARD
/ OK

for eg, then restart postfix (pcre files do not need to be/can't be postmap'd)