With postfix-2.6.6-2.2.el6_1.x86_64 on CentOS 6.4 is there please a way to inspect OUTGOING mails and silently drop them (i.e. do not send them) if the recipient looks like us.er.n.a.me@gmail.com (i.e. gmail.com domain and more than 3 dots in the username part of the address)?
Can header_checks be used for that or is it for INCOMING mail only?
Below is the current configuration (the postconf -n
output) of Postfix at my server (I use virtual_alias_domains to accept mail for several Drupal sites hosted as Apache vhosts at my dedicated server and I want to stop sending the registration mail for fake users):
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = all
inet_protocols = ipv4
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_generic_maps = hash:/etc/postfix/generic
unknown_local_recipient_reject_code = 550
virtual_alias_domains = videoskat.de balkan-preferans.de simplex.ru preferans.de larissa-farber.de bukvy.de
virtual_alias_maps = hash:/etc/postfix/virtual
UPDATE:
Thanks to Jenny D, the following seems to work
/etc/postfix/header_checks:
/^To: \S+\.\S+\.\S+\.\S+@gmail.com$/i DISCARD
/etc/postfix/main.cf:
header_checks = pcre:/etc/postfix/header_checks