1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/usr/local/bin/python
"""Send password reminders for all lists to all users.
We accumulate users and their passwords, and use the last list to send a
single message to each user with their complete collection of passwords,
rather than sending a single message for each password."""
__version__ = "$Revision: 408 $"
# This puppy should probably do lots of logging.
import sys, os, string
sys.path.append('/home/mailman/mailman/modules')
import maillist, mm_cfg, mm_message, mm_utils
users = {} # user: (listname, password, url)
USERPASSWORDSTEXT = """
This is a reminder, sent out once a month, about your %s
mailing list memberships. It includes your subscription info and
how to use it to change it or unsubscribe from a list.
Passwords for %s:
%s
%s
You can visit the URLs to change your membership status or configuration,
including unsubscribing, setting digest-style delivery or disabling
delivery altogether (e.g., for a vacation), and so on.
In addition to the URL interfaces, you can also use email to make such
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.
If you have questions, problems, comments, etc, 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:
if len(l) > 9:
table.append("%s\n %-10s\n%s\n" % (l, p, u))
else:
table.append("%-10s %-10s\n%s\n" % (l, p, u))
header = ("%-10s %-10s\n%-10s %-10s"
% ("List", "Password // URL", "----", "--------"))
text = USERPASSWORDSTEXT % (list.host_name,
user,
header,
string.join(table, "\n"),
l, list.host_name,
list.host_name)
list.SendTextToUser(subject = subj,
recipient = user,
text = text,
sender = mm_cfg.MAILMAN_OWNER,
add_headers = ["X-No-Archive: yes"])
def main():
"""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 mm_utils.list_names():
list = maillist.MailList(name)
list_name = list.real_name
for user, password in list.passwords.items():
url = list.GetOptionsURL(user)
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)
if __name__ == "__main__":
main()
|