summaryrefslogtreecommitdiff
path: root/cron
diff options
context:
space:
mode:
authormailman1998-02-22 18:15:07 +0000
committermailman1998-02-22 18:15:07 +0000
commit71f38b9047401ce4d44d17dc0248e69120a97527 (patch)
tree44777e711e96b9d2778f81122e4e1d8f65485984 /cron
parentfae7dd0d5452fdd64c9ab8325a4d29cf55695b22 (diff)
downloadmailman-71f38b9047401ce4d44d17dc0248e69120a97527.tar.gz
mailman-71f38b9047401ce4d44d17dc0248e69120a97527.tar.zst
mailman-71f38b9047401ce4d44d17dc0248e69120a97527.zip
Send each user all their passwords in a single message, rather than
sending them in a bunch. MailAllPasswords() - mostly cribbed from mm_deliver:Deliver.MailUserPassword(), but it takes the information for all users and sends a message to each with all their password info.
Diffstat (limited to 'cron')
-rwxr-xr-xcron/mailpasswds88
1 files changed, 71 insertions, 17 deletions
diff --git a/cron/mailpasswds b/cron/mailpasswds
index 8dea4c563..59dbf5e1c 100755
--- a/cron/mailpasswds
+++ b/cron/mailpasswds
@@ -1,32 +1,86 @@
#!/usr/local/bin/python
-# This script gets called by cron. It goes through all the lists,
-# and locks each list as it processes it. It goes through every
-# address, and mails a password reminder. It isn't a big enough deal
-# to worry about what happens if someone is on multiple lists.
-#
-# This puppy should probably do lots of logging.
+"""This script gets called by cron. It goes through all the lists,
+and locks each list as it processes it. It goes through every
+address, and mails a password reminder. It isn't a big enough deal
+to worry about what happens if someone is on multiple lists."""
+# This puppy should probably do lots of logging.
-import sys, os
+import sys, os, string
sys.path.append('/home/mailman/mailman/modules')
import maillist, mm_cfg, mm_message
-def MailPasswords(list):
- for user in list.passwords.keys():
- list.MailUserPassword(user)
+users = {} # user: (listname, password, url)
-dirs = os.listdir(mm_cfg.LIST_DATA_DIR)
-for dir in dirs:
- if not (os.path.exists(os.path.join(
- os.path.join(mm_cfg.LIST_DATA_DIR, dir), 'config.db'))):
- continue
+USERPASSWORDSTEXT = """
+This is a reminder, sent out once a month, about your %s
+mailing list memberships. It includes your configuration info and
+how to use it to change it or unsubscribe from a list. Here are the
+details:
+
+%s
+%s
+
+The URLs have web-based interfaces for changing your membership status or
+configuration for the respective list.
+
+In addition to the URL web interfaces, you can also use email to make the
+changes. For more info, send a message to the '-request' address of the
+list (for example, %s-request@%s) containing just the word
+'help' in the message body, and an email message will be sent to you with
+instructions.
+
+Questions, problems, comments?
+Please send them to mailman-owner@%s. Thanks!
+"""
+
+def MailAllPasswords(list, users):
+ """Send each user their complete list of passwords.
+
+ The list can be any random one - it is only used for the message
+ delivery mechanism."""
+ subj = '%s maillist memberships reminder\n' % list.host_name
+ for user, data in users.items():
+ table = []
+ for l, p, u in data:
+ table.append("%-10s %-10s %s" % (l, p, u))
+ header = ("%-10s %-10s %s\n%-10s %-10s %s"
+ % ("List", "Password", "URL", "----", "--------", "---"))
+ text = USERPASSWORDSTEXT % (list.host_name,
+ header,
+ string.join(table, "\n"),
+ l, list.host_name,
+ list.host_name)
+ list.SendTextToUser(subject = subj,
+ recipient = user,
+ text = text)
+
+# Consolidate all the list/url/password info for each user, so we send
+# the user a single message with the info for all their lists on this
+# site.
+list = None
+for name in maillist.list_names():
try:
- list = maillist.MailList(dir)
+ list = maillist.MailList(name)
except:
continue
- MailPasswords(list)
+ url = list.GetScriptURL('listinfo')
+ list_name = list.real_name
+ for user, password in list.passwords.items():
+ if users.has_key(user):
+ users[user].append(list_name, password, url)
+ else:
+ users[user] = [(list_name, password, url)]
+ # Unlocking each list after identifying passwords, but before having
+ # the consolidated list, means that there is a window for discrepancy
+ # between the reported and actual password. Big deal - if the user
+ # changed the password in the meanwhile, they'll realize it, and it's
+ # not worth the extra deadlock risk.
list.Unlock()
+
+if list:
+ MailAllPasswords(list, users)