Add rule to auto-discard "AutoReply" messages from list members
When people are communicating on Mailman3 lists, some set up automatic responders for out-of-office, etc. and get let through the system to list recipients.
Unfortunately, this is bad behavior and appears to not be caught by default. I'd like to set up some kind of rule globally rather than per-list that would check if a message is an automatic reply (based on a set of criteria we've come up with programmatically on our previous custom implementation of lists) and then default-discard those messages.
Is there a way with custom rules to implement this? We're looking for certain strings on the subject line or other headers to determine "Discard" cases in our custom list implementations, but we are hoping we can implement this with customized rules in Mailman3 to achieve this goal. How would we structure that type of rule, and do we check the message object or the msgdata instead?
Thomas
On 11/16/23 01:07, Thomas Ward via Mailman-users wrote:
When people are communicating on Mailman3 lists, some set up automatic responders for out-of-office, etc. and get let through the system to list recipients.
Unfortunately, this is bad behavior and appears to not be caught by default. I'd like to set up some kind of rule globally rather than per-list that would check if a message is an automatic reply (based on a set of criteria we've come up with programmatically on our previous custom implementation of lists) and then default-discard those messages.
Is there a way with custom rules to implement this? We're looking for certain strings on the subject line or other headers to determine "Discard" cases in our custom list implementations, but we are hoping we can implement this with customized rules in Mailman3 to achieve this goal. How would we structure that type of rule, and do we check the message object or the msgdata instead?
You can implement a custom rule and a custom chain to do this, but you'd
need to set that as the default chain on every existing list. Setting
the default chain can be scripted using mailman shell
pretty easily
though.
For any new lists, you can setup a custom style(s) and ensure that your new chain is the default chain for new lists.
https://gitlab.com/mailman/example-mailman-plugin/-/blob/master/example_mail...
^ is an example plugin you can use as a starting point for your plugin
and you will also see example rule at rules/rules.py
.
https://gitlab.com/mailman/mailman/-/tree/master/src/mailman/rules
The above existing rules in Mailman's source code should serve as examples on how you can look at a header or body of the email. For example, approved.py looks for certain headers (var HEADERS in the file) or iterates through the body to look for something that looks like a header too ("Approved: <password>").
Once you have the rule, you can insert it in the right place in the chain. You can use the default-posting-chain
https://gitlab.com/mailman/mailman/-/blob/master/src/mailman/chains/builtin....
as your starting point (example plugin doesn't have an example chain yet, but it would look similar to inbuilt chains, under a "chains/" directory in the plugin).
In the chain, you can also define what happens if rule matches. Rules
only return True/False, based on whether the rule matched and chain can
define if that should put the message into a separate queue (e.g.
('my-new-rule', LinkAction.jump , 'hold'), etc. or do nothing
('my-new-rule', LinkAction.defer
, None).
There are also example styles defined in the plugin
https://gitlab.com/mailman/example-mailman-plugin/-/blob/master/example_mail...
You mostly want to update posting_chain
property on the 'mlist' object
for the style.
You can find examples again in the source tree under
src/mailman/styles
directory.
To configure the default style for new lists, you can add the following to your mailman.cfg:
[styles] default: my-new-style
ref: https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/config/docs...
Let us know if you have any questions on the same.
-- thanks, Abhilash Raj (maxking)
Abhilash Raj writes:
You can implement a custom rule and a custom chain to do this, but you'd need to set that as the default chain on every existing list. Setting the default chain can be scripted using
mailman shell
pretty easily though.
I'd just
from mailman.config import config config.chains['default-posting-chain'].insert( right_place, vacation_program_considered_harmful_rule)
TBQH. If I was feeling really paranoid I'd search for the preceding and following rules expected, and if found insert there.
There really should be a default-posting-chain option (and default-posting-pipeline option for that matter) in schema.cfg.
On Wed, Nov 15, 2023 at 10:38 PM Thomas Ward via Mailman-users < mailman-users@mailman3.org> wrote:
When people are communicating on Mailman3 lists, some set up automatic responders for out-of-office, etc. and get let through the system to list recipients.
Unfortunately, this is bad behavior and appears to not be caught by default. I'd like to set up some kind of rule globally rather than per-list that would check if a message is an automatic reply (based on a set of criteria we've come up with programmatically on our previous custom implementation of lists) and then default-discard those messages.
Is there a way with custom rules to implement this? We're looking for certain strings on the subject line or other headers to determine "Discard" cases in our custom list implementations, but we are hoping we can implement this with customized rules in Mailman3 to achieve this goal. How would we structure that type of rule, and do we check the message object or the msgdata instead?
How about using the rules inside your MTA to check the subject for the common words used by autoresponders like: Out of Office | Auto-Reply | Autoresponse | Auto Reply And if the subject matches, do NOT pass that to the transport that delivers to MM3
Just an Idea borrowed from the rules we (in the Exim MTA world) use to process Out Of Office responses.
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-) [How to ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html]
Thomas Ward via Mailman-users writes
Unfortunately, this is bad behavior and appears to not be caught by default.
I deal with that at the exim level. At this time I only have one list
root@tagol/etc/mail# cat exim.filter # Exim filter
# Auto-Submitted: auto-replied if $h_to: contains "bibnez@folks.email" and $h_Auto-Submitted: contains "auto-replied" then headers add "Old-Subject: $h_subject:" headers remove "Subject" headers add "Subject: RAUS ($h_old-subject:)" headers remove "Old-Subject" deliver "juergen.plieninger@uni-tuebingen.de" endif
Thus if the header Auto_Submitted contains auto-replied, I forward it to Jürgen, my list boss, just in case it is actually ham, but I change the subject so that he can easily spot that it was filtered.
This is not 100% tight, as there are bad auto-reply agents creating mails that don't have an auto-submitted header.
Hope this helps somebody out there.
-- Written by Thomas Krichel http://openlib.org/home/krichel on his 21349th day.
On Thu, Nov 16, 2023 at 12:45 PM Thomas Krichel <krichel@openlib.org> wrote:
Thomas Ward via Mailman-users writes
Unfortunately, this is bad behavior and appears to not be caught by default.
I deal with that at the exim level. At this time I only have one list
root@tagol/etc/mail# cat exim.filter # Exim filter
# Auto-Submitted: auto-replied if $h_to: contains "bibnez@folks.email" and $h_Auto-Submitted: contains "auto-replied"
If you have several lists using the same domain suffix, this would become:
if $h_to: contains "(LIST1|LIST2|LISTX)@domain.name" and $h_Auto-Submitted: contains "auto-replied" then ...
If you have lists using different email addresses, then you just substitute the $h_to in another filter rule.
But then maybe Mr. Thomas Ward uses Postfix or Sendmail, in which case this is all useless/greek to him :)
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-) [How to ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html]
Odhiambo Washington writes:
If you have lists using different email addresses, then you just substitute the $h_to in another filter rule.
But then maybe Mr. Thomas Ward uses Postfix or Sendmail, in which case this is all useless/greek to him :)
If he's done any MTA configuration, I'm sure he'll treat it as pseudo-code and translate to the language he needs without trouble. So please don't hesistate to provide code from your site (appropriately redacted, of course) even if you know the OP uses different software.
The big question about the usefulness of these posts is whether his users have RFC 3834 conforming vacation programs that know about the Auto-Submitted field.
I didn't know my homework bot was conformant until I just checked -- thank you Exim4!
Steve
participants (5)
-
Abhilash Raj
-
Odhiambo Washington
-
Stephen J. Turnbull
-
Thomas Krichel
-
Thomas Ward