#! /usr/bin/env python # # Copyright (C) 2014-2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. """Reprint or remail a list's welcome message for a user. Usage: %(PROGRAM)s [options] listname user_address Options: -m / --mail Mail the welcome to the user. The default is to just print it. -h / --help Print this message and exit. This script must run from Mailman's bin/ directory. """ import sys import paths import getopt from Mailman import mm_cfg from Mailman import Errors from Mailman import Utils from Mailman.i18n import _ from Mailman.MailList import MailList PROGRAM = sys.argv[0] def usage(code, msg=''): if code: fd = sys.stderr else: fd = sys.stdout print >> fd, _(__doc__) if msg: print >> fd, msg sys.exit(code) def printit(mlist, name, password, digest, text=''): pluser = mlist.getMemberLanguage(name) if mlist.welcome_msg: welcome = Utils.wrap(mlist.welcome_msg) + '\n' else: welcome = '' if mlist.umbrella_list: addr = mlist.GetMemberAdminEmail(name) 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, %(addr)s.''')) else: umbrella = '' # get the text from the template text += Utils.maketext( 'subscribeack.txt', {'real_name' : mlist.real_name, 'host_name' : mlist.host_name, 'welcome' : welcome, 'umbrella' : umbrella, 'emailaddr' : mlist.GetListEmail(), 'listinfo_url': mlist.GetScriptURL('listinfo', absolute=True), 'optionsurl' : mlist.GetOptionsURL(name, absolute=True), 'password' : password, 'user' : mlist.getMemberCPAddress(name), }, lang=pluser, mlist=mlist) print text def main(): try: opts, args = getopt.getopt( sys.argv[1:], 'mh', ['mail', 'help']) except getopt.error, msg: usage(1, msg) mail = False for opt, arg in opts: if opt in ('-h', '--help'): usage(0) if opt in ('-m', '--mail'): mail = True if len(args) != 2: usage(1, _('Exactly one listname and user address required')) try: list = args[0].lower() mlist = MailList(list, lock=False) name = args[1].lower() password = mlist.getMemberPassword(name) digest = mlist.getMemberOption(name, mm_cfg.Digests) except Errors.MMListError: usage(2, _('No such list: %(list)s')) except (Errors.MMMemberError, Errors.MemberError): usage(2, _('No such member: %(name)s')) if mail: mlist.SendSubscribeAck(name, password, digest) else: printit(mlist, name, password, digest) if __name__ == '__main__': main()