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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# Copyright (C) 1998 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""Mixin class with message delivery routines."""
import os
import string
from Mailman import mm_cfg
from Mailman import Errors
from Mailman import Utils
from Mailman import Message
from Mailman.Handlers import HandlerAPI
class Deliverer:
def SendSubscribeAck(self, name, password, digest):
if not self.send_welcome_msg:
return
if self.welcome_msg:
welcome = Utils.wrap(self.welcome_msg) + '\n'
else:
welcome = ''
if self.umbrella_list:
umbrella = Utils.wrap('''\
Note: Since this is a list of mailing lists, administrative
notices like the password reminder will be sent to
your membership administrative address, %s.
''' % self.GetMemberAdminEmail(name))
else:
umbrella = ''
# get the text from the template
text = Utils.maketext(
'subscribeack.txt',
{'real_name' : self.real_name,
'host_name' : self.host_name,
'welcome' : welcome,
'umbrella' : umbrella,
'emailaddr' : self.GetListEmail(),
'listinfo_url': self.GetAbsoluteScriptURL('listinfo'),
'optionsurl' : self.GetAbsoluteOptionsURL(name),
'password' : password,
})
if digest:
digmode = ' (Digest mode)'
else:
digmode = ''
msg = Message.UserNotification(
self.GetMemberAdminEmail(name), self.GetRequestEmail(),
'Welcome to the "%s" mailing list%s' % (self.real_name, digmode),
text)
HandlerAPI.DeliverToUser(self, msg)
def SendUnsubscribeAck(self, name):
msg = Message.UserNotification(
self.GetMemberAdminEmail(name), self.GetAdminEmail(),
'Unsubscribed from "%s" mailing list' % self.real_name,
Utils.wrap(self.goodbye_msg))
HandlerAPI.DeliverToUser(self, msg)
def MailUserPassword(self, user):
listfullname = '%s@%s' % (self.real_name, self.host_name)
ok = 1
# find the lowercased version of the user's address
user = self.FindUser(user)
if user and self.passwords.has_key(user):
cpuser = self.GetUserSubscribedAddress(user)
recipient = self.GetMemberAdminEmail(cpuser)
subject = '%s mailing list reminder' % listfullname
adminaddr = self.GetAdminEmail()
requestaddr = self.GetRequestEmail()
# get the text from the template
text = Utils.maketext(
'userpass.txt',
{'user' : cpuser,
'listname' : self.real_name,
'password' : self.passwords[user],
'options_url': self.GetAbsoluteOptionsURL(user),
'requestaddr': requestaddr,
'adminaddr' : adminaddr,
})
else:
ok = 0
recipient = self.GetAdminEmail()
subject = '%s user %s missing password!' % (listfullname, user)
text = Utils.maketext(
'nopass.txt',
{'username' : `user`,
'internal_name': self.internal_name(),
})
msg = Message.UserNotification(recipient, requestaddr, subject, text)
msg['X-No-Archive'] = 'yes'
HandlerAPI.DeliverToUser(self, msg)
if not ok:
raise Errors.MMBadUserError
|