Mailinglist Archive: opensuse (2827 mails)

< Previous Next >
Re: [opensuse] Postfix: howto block CC-overloaded mail (regular expression)
  • From: "Amedee Van Gasse" <amedee@xxxxxxxxx>
  • Date: Fri, 19 Dec 2008 11:21:57 +0100 (CET)
  • Message-id: <41127.193.121.250.194.1229682117.squirrel@xxxxxxxxxxxxxxxx>
On Fri, December 19, 2008 11:13, Amedee Van Gasse wrote:
On Thu, December 18, 2008 16:55, Per Jessen wrote:
Amedee Van Gasse wrote:

Hello,

I have a question about Postfix header checks and regular expressions.
In my main.cf I have:

header_checks = regexp:/etc/postfix/maps/header_checks

and in header_checks I have:

/^[To|Cc]:.*,.*,.*,.*,.*,.*,.*,.*,.*,.*$/ REJECT Too many
recipients. Please use BCC.

I *think* that this means:
* Check for a header that starts with either "To" or "Cc".
* any string, followed by a comma (email address separator)
* check for 9 comma's or 10 strings (addresses)

In other words, if you send me an email and you over-abuse the To or
CC-field, your mail will be rejected with the message "Too many
recipients. Please use BCC."

I want to do this because I'm tired of educating always the same
people. I don't want emails (usually chain mail or "funny
powerpoints") where the receipient list is longer than the actual
message. Even if it's from family.

Unfortunately, it doesn't seem to work. Mail with more than 10 people
in the CC is still getting trough.

Try this instead:

/^(To|Cc):([^,]+,){9}/i REJECT Too many

[] = character class
() = grouping

Thanks all.
I forgot that a regex is greedy.
And thank you Per for optimizing.

I'm going to test now.

Thanks all, it worked.
The sender gets a nice message:

Server replied: 550 5.7.1 Too many recipients. Please use BCC.

--
Amedee

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups