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


Thanks to Jenny D, the following seems to work


/^To: \S+\.\S+\.\S+\.\S+@gmail.com$/i DISCARD


header_checks = pcre:/etc/postfix/header_checks

It can be done - see the postfix documentation for a description of how and where the various types of filters are used.

In this case, though, I'd suggest that catching the invalid subscriptions would be better done at the registration point, e.g. by using a CAPTCHA of some sort for any account matching "three dots before @google.com".

  • I do not want to use CAPTCHA at the moment and am looking for the postfix workaround to stop the flood. My problem is - if I try smtp_header_checks with DISCARD action - the postfix.org/header_checks.5.html says it is not supported. – Alexander Farber Nov 22 '13 at 9:55
  • You should use header_checks, not smtp_header_checks . – Jenny D Nov 22 '13 at 10:01
  • But I'd like to discard OUTGOING mail. – Alexander Farber Nov 22 '13 at 10:08
  • 2
    Yes, and the way to do that is to use header_checks before putting the mail in the queue for outbound delivery. – Jenny D Nov 22 '13 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.