1# -*- python -*- 2# 3# Copyright (C) 1998-2018 by the Free Software Foundation, Inc. 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License 7# as published by the Free Software Foundation; either version 2 8# of the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 19"""Send a message to the mailing list owner. 20 21All messages to a list's -owner address should be piped through this script. 22The -owner address is defined to be delivered directly to the list owners plus 23the list moderators, with no intervention for bounce processing. 24 25Stdin is the mail message, and argv[1] is the name of the target mailing list. 26""" 27 28import sys 29 30import paths 31from Mailman import mm_cfg 32from Mailman import Utils 33from Mailman.i18n import _ 34from Mailman.Queue.sbcache import get_switchboard 35from Mailman.Logging.Utils import LogStdErr 36 37LogStdErr('error', 'mailowner') 38 39 40 41def main(): 42 try: 43 listname = sys.argv[1] 44 except IndexError: 45 print >> sys.stderr, _('mailowner got no listname.') 46 sys.exit(1) 47 # Make sure the list exists 48 if not Utils.list_exists(listname): 49 print >> sys.stderr, _( 50 'mailowner script, list not found: %(listname)s') 51 sys.exit(1) 52 # Queue the message for the owners. We will send them through the 53 # incoming queue because we need some processing done on the message. The 54 # processing is minimal though, so craft our own pipeline, expressly for 55 # the purpose of delivering to the list owners. 56 inq = get_switchboard(mm_cfg.INQUEUE_DIR) 57 inq.enqueue(sys.stdin.read(), 58 listname=listname, 59 _plaintext=1, 60 envsender=Utils.get_site_email(extra='bounces'), 61 pipeline=mm_cfg.OWNER_PIPELINE, 62 toowner=1) 63 64 65 66if __name__ == '__main__': 67 main() 68