Reject an email message with too many recipients with Postfix

The following config will reject a message when more than 10 recipients are in the TO: and/or CC: fields.

/etc/postfix/main.cf:

# restrict based on message header content 
header_checks = pcre:/etc/postfix/header_checks

/etc/postfix/header_checks:

/^To:([^@]*@){10,}/	REJECT Sorry, your message has too many recepients.
/^Cc:([^@]*@){10,}/	REJECT Sorry, your message has too many recepients.

Solution based on a post at linuxquestions.org.

1 Comment

  • 1. Willy replies at 29th November 2013, 8:21 am :

    So I´m with the same problem, when I use with one digit is ok, how to {1,}…{9,} after this, like you don´t works.

    How you fixed this?

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).