
I run a large community based mailing list using mailman (version 2.1.9, I know a bit old, but that is what the hosting service provides) and I have a couple of users that while normally ok, at times get into arguments with each other on the list. A thought came up, would it be possible to configure the list so that if one of these persons replies to a message from another, the message gets held for review. The people are a bit lazy, so when they do the reply all (list is setup so reply goes to sender, reply all goes to list and send) the other persons email shows up a To: or Cc:
The question is, can a spam filter be set up to check both the From fields and the To/CC fields?

Richard Damon wrote:
The question is, can a spam filter be set up to check both the From fields and the To/CC fields?
Yes, but it's awkward at best. header_filter_rules are Python regular expressions that are matched against the entire set of message headers in MULTILINE and IGNORECASE mode. The awkwardness comes about because you don't know if the From: precedes or follows the To: or Cc: so you need to check both possibilities. A regexp like
^From:.*user1@example\.com[^\177]*^(To:|Cc:).*user2@example\.net'
will match a From: header containing user1@example.com followed by a To: or Cc: header containing user2@example.net.
Note the use of [^\177]* to skip all the intervening headers between From: and To: or Cc:. [^\177] will match anything that isn't a rubout (octal 177, hex 7F) including newlines. There should be no rubouts in email message headers. You can't use .* here because . won't match a newline, and you can't use (?s) to set 'dot matches all' because that would allow .*user1@example\.com to match beyond the From: header.
Then you could add a second regexp to the rule
^(To:|Cc:).*user1@example\.com[^\177]*^From:.*user2@example\.net'
to cover the case where the To: or Cc: precedes From: and then add two more with the roles of user1 and user2 reversed.
You might get away with combining all this into one as
^(From:|To:|Cc:).*(user1@example\.com|user2@example\.net)[^\177]*^(From:|To:|Cc:).*(user1@example\.com|user2@example\.net)'
(all on one line). This would match any From:, To: or Cc: containing either user1@example.com followed by a From:, To: or Cc: containing user2@example.net. The drawback of this all in one is it would match a message From: a 3rd party To: one of the users with Cc: to the other and would match a message from one of the users with a Cc: to herself.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

On 9/27/11 5:33 PM, Mark Sapiro wrote:
Thank you, the [^\177]* should be the trick to get the filter to scan over multiple lines. Will have to think about handling the unknown order of the tag. I don't think it is a problem catching messages they sent cc to themselves, and a message to both of them could be worth looking at too, likely A (not one of them) posted something, B (one of them) replied to A and list, C (another of them) replies back to A, B and the list a scathing reply that is rejected, but A (being CC by C) replies back to B, C and the list, quoting that material.

On Tue, 27 Sep 2011 17:10:34 +0100, Richard Damon
<Richard@damon-family.org> wrote:
Mark's solution is, of course, more technically elegant than what I'm abut
to suggest but I wonder if, trying to think sideways a little, you could
catch the majority of the messages you wish to moderate by one or both of:
- set 'max_num_recipients' to 2 so anything with a Cc is caught
- set a spam trap for anything that already has [subject-prefix] in the
subject line.
= Malcolm.
-- Using Opera's revolutionary email client: http://www.opera.com/mail/

On 9/28/11 5:06 AM, Malcolm Austen wrote:
That would catch EVERYONES replies to posts, which I don't want. There are a couple of small groups that just don't see eye to eye on some issues, and sometimes go after each other. Since the list gets about 100 messages a day, I don't want to do anything that causes a large number of messages to end up in the moderation queue.

Richard Damon wrote:
The question is, can a spam filter be set up to check both the From fields and the To/CC fields?
Yes, but it's awkward at best. header_filter_rules are Python regular expressions that are matched against the entire set of message headers in MULTILINE and IGNORECASE mode. The awkwardness comes about because you don't know if the From: precedes or follows the To: or Cc: so you need to check both possibilities. A regexp like
^From:.*user1@example\.com[^\177]*^(To:|Cc:).*user2@example\.net'
will match a From: header containing user1@example.com followed by a To: or Cc: header containing user2@example.net.
Note the use of [^\177]* to skip all the intervening headers between From: and To: or Cc:. [^\177] will match anything that isn't a rubout (octal 177, hex 7F) including newlines. There should be no rubouts in email message headers. You can't use .* here because . won't match a newline, and you can't use (?s) to set 'dot matches all' because that would allow .*user1@example\.com to match beyond the From: header.
Then you could add a second regexp to the rule
^(To:|Cc:).*user1@example\.com[^\177]*^From:.*user2@example\.net'
to cover the case where the To: or Cc: precedes From: and then add two more with the roles of user1 and user2 reversed.
You might get away with combining all this into one as
^(From:|To:|Cc:).*(user1@example\.com|user2@example\.net)[^\177]*^(From:|To:|Cc:).*(user1@example\.com|user2@example\.net)'
(all on one line). This would match any From:, To: or Cc: containing either user1@example.com followed by a From:, To: or Cc: containing user2@example.net. The drawback of this all in one is it would match a message From: a 3rd party To: one of the users with Cc: to the other and would match a message from one of the users with a Cc: to herself.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

On 9/27/11 5:33 PM, Mark Sapiro wrote:
Thank you, the [^\177]* should be the trick to get the filter to scan over multiple lines. Will have to think about handling the unknown order of the tag. I don't think it is a problem catching messages they sent cc to themselves, and a message to both of them could be worth looking at too, likely A (not one of them) posted something, B (one of them) replied to A and list, C (another of them) replies back to A, B and the list a scathing reply that is rejected, but A (being CC by C) replies back to B, C and the list, quoting that material.

On Tue, 27 Sep 2011 17:10:34 +0100, Richard Damon
<Richard@damon-family.org> wrote:
Mark's solution is, of course, more technically elegant than what I'm abut
to suggest but I wonder if, trying to think sideways a little, you could
catch the majority of the messages you wish to moderate by one or both of:
- set 'max_num_recipients' to 2 so anything with a Cc is caught
- set a spam trap for anything that already has [subject-prefix] in the
subject line.
= Malcolm.
-- Using Opera's revolutionary email client: http://www.opera.com/mail/

On 9/28/11 5:06 AM, Malcolm Austen wrote:
That would catch EVERYONES replies to posts, which I don't want. There are a couple of small groups that just don't see eye to eye on some issues, and sometimes go after each other. Since the list gets about 100 messages a day, I don't want to do anything that causes a large number of messages to end up in the moderation queue.
participants (3)
-
Malcolm Austen
-
Mark Sapiro
-
Richard Damon