Postfix "Content Filter" setup to reject emails with too many recipients in TO: field
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.)
Here's a pcre regexp that matches at least 5 '@' in the To header:
Code:
^To: ([^@]*@){5,}
Note that if you reject such messages, you will also be filtering incoming messages
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
I tested the expression in my first post with pcretest. For postfix, I think you
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.
Hi, bahadirtonguc. In the course of this thread, you went from writing a nonsensical regular expression at the beginning to solving your own problem by the end. So, I would say that it did work out. Good job!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.