1
# Copyright (C) 2002 by the Free Software Foundation, Inc.
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
unsubscribe [password] [address=<address>]
19
Unsubscribe from the mailing list. If given, your password must match
20
your current password. If omitted, a confirmation email will be sent
21
to the unsubscribing address. If you wish to unsubscribe an address
22
other than the address you sent this request from, you may specify
23
`address=<address>' (no brackets around the email address, and no
27
from email.Utils import parseaddr
29
from Mailman import Errors
30
from Mailman.i18n import _
41
def process(res, args):
47
if arg.startswith('address='):
52
res.results.append(_('Usage:'))
53
res.results.append(gethelp(mlist))
56
# Fill in empty defaults
58
realname, address = parseaddr(res.msg['from'])
59
if not mlist.isMember(address):
60
listname = mlist.real_name
62
_('%(address)s is not a member of the %(listname)s mailing list'))
64
# If we're doing admin-approved unsubs, don't worry about the password
65
if mlist.unsubscribe_policy:
67
mlist.DeleteMember(address, 'mailcmd')
68
except Errors.MMNeedApproval:
69
res.results.append(_("""\
70
Your unsubscription request has been forwarded to the list administrator for
72
elif password is None:
73
# No password was given, so we need to do a mailback confirmation
74
# instead of unsubscribing them here.
75
cpaddr = mlist.getMemberCPAddress(address)
76
mlist.ConfirmUnsubscription(cpaddr)
77
# We don't also need to send a confirmation to this command
80
# No admin approval is necessary, so we can just delete them if the
82
oldpw = mlist.getMemberPassword(address)
84
res.results.append(_('You gave the wrong password'))
86
mlist.ApprovedDeleteMember(address, 'mailcmd')
87
res.results.append(_('Unsubscription request succeeded.'))