summaryrefslogtreecommitdiff
path: root/Mailman/MailList.py
diff options
context:
space:
mode:
authorbwarsaw2002-05-28 03:06:45 +0000
committerbwarsaw2002-05-28 03:06:45 +0000
commit631fc7e2928c96061021db51a78e3aaba9e6aaf1 (patch)
tree5f83b84c4a75de8094ea055d12d853635e0e6961 /Mailman/MailList.py
parentbd750d5999c9d16c8996f5363acfc07fc62720ca (diff)
downloadmailman-631fc7e2928c96061021db51a78e3aaba9e6aaf1.tar.gz
mailman-631fc7e2928c96061021db51a78e3aaba9e6aaf1.tar.zst
mailman-631fc7e2928c96061021db51a78e3aaba9e6aaf1.zip
InitVars(): Add a new attribute hold_and_cmd_autoresponses which is a
dictionary mapping sender addresses (they don't have to be members) to a 2-tuple of information (date, count). date is a 3-tuple of (year, month, day) and count is the number of auto-responses sent to the sender today. autorespondToSender(): This method is called whenever we're about to send a response to a -request message, or a hold notification. It returns 1 if the caller should send a normal autoresponse, and 0 otherwise. When we've just exceeded the maximum number of autoresponses, we send a message indicating that no more responses will be sent today (instead of the normal autoresponse).
Diffstat (limited to 'Mailman/MailList.py')
-rw-r--r--Mailman/MailList.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 92d157584..43b5d6d44 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -340,6 +340,10 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
self.ban_list = []
# BAW: This should really be set in SecurityManager.InitVars()
self.password = crypted_password
+ # Max autoresponses per day. A mapping between addresses and a
+ # 2-tuple of the date of the last autoresponse and the number of
+ # autoresponses sent on that date.
+ self.hold_and_cmd_autoresponses = {}
# Only one level of mixin inheritance allowed
for baseclass in self.__class__.__bases__:
@@ -1249,6 +1253,48 @@ bad regexp in bounce_matching_header line: %s
return line
return 0
+ def autorespondToSender(self, sender):
+ """Return true if Mailman should auto-respond to this sender.
+
+ This is only consulted for messages sent to the -request address, or
+ for posting hold notifications, and serves only as a safety value for
+ mail loops with email 'bots.
+ """
+ today = time.localtime()[:3]
+ info = self.hold_and_cmd_autoresponses.get(sender)
+ if info is None or info[0] <> today:
+ # First time we've seen a -request/post-hold for this sender
+ self.hold_and_cmd_autoresponses[sender] = (today, 1)
+ # BAW: no check for MAX_AUTORESPONSES_PER_DAY <= 1
+ return 1
+ date, count = info
+ if count < 0:
+ # They've already hit the limit for today.
+ syslog('vette', '-request/hold autoresponse discarded for: %s',
+ sender)
+ return 0
+ if count >= mm_cfg.MAX_AUTORESPONSES_PER_DAY:
+ syslog('vette', '-request/hold autoresponse limit hit for: %s',
+ sender)
+ self.hold_and_cmd_autoresponses[sender] = (today, -1)
+ # Send this notification message instead
+ text = Utils.maketext(
+ 'nomoretoday.txt',
+ {'sender' : sender,
+ 'listname': '%s@%s' % (self.real_name, self.host_name),
+ 'num' : count,
+ 'owneremail': self.GetOwnerEmail(),
+ })
+ msg = Message.UserNotification(
+ sender, self.GetOwnerEmail(),
+ _('Last autoresponse notification for today'),
+ text)
+ msg.send(self)
+ return 0
+ self.hold_and_cmd_autoresponses[sender] = (today, count+1)
+ return 1
+
+
#
# Multilingual (i18n) support