Postfix "Content Filter" setup to reject emails with too many recipients in TO: field
Dear all,
I am willing to setup a content filter to reject messages with too many recipients in TO: or CC: fiels but to let for BCC: This way suppose I may avoid mistakes such as putting all the recipients in TO: or CC: fields instead of BCC: so this way they wont ever see each other. (Some of my colleagues had done it quite a few times in the past and exposed all our private address book to every recipient.) Appreciate your help Regards Bahadir |
It's quite strange that nobody could reply however I helped myself reading a lot about this question and would like to share with others:
in header_checks, write a regexp like below which regret not working and needs a bit modification /^To:[/.*/@/.*/]{5}$ Don't know where I am doing wrong but feels like very close to the answer though :) |
You probably need to work in a delimiter between emails as well
|
Here's a pcre regexp that matches at least 5 '@' in the To header:
Code:
^To: ([^@]*@){5,} from the outside, so for example you would reject mail addressed to you and four other recipients. |
It aint working mate. Still can successfully send any kind of messages outbound. By the way, I dont use this server for inbound traffic so not concerned about filtering incoming messages.
|
In that case, you should post your header_checks file, so people can see what's not working. Your file should look something like this:
Code:
/^To: ([^@]*@){5,}.*/ ACTION need to match the entire line (i.e. header), which is why you need the ".*" at the end. I haven't tested it with postfix, so you might have to improve it. |
Here is the solution :
/^To: (.*@.*){5,}/ REJECT too many recipients /^Cc: (.*@.*){5,}/ REJECT too many recipients |
You're welcome.
|
Berhanine, thanks for your help but regret it did not work out. So I posted the correct syntax
|
Quote:
|
worked for me
I realize this is an old post, but just wanted to report what worked for me, in case someone else is looking to do this.
Berhanie's solution worked, here's my config. /etc/postfix/main.cf: Code:
# restrict based on message header content Code:
/^To:([^@]*@){10,}/ REJECT Sorry, your message has too many recepients. Quote:
Quote:
Reject an email message with too many recipients with Postfix |
All times are GMT -5. The time now is 11:37 PM. |