~mailman-coders/mailman/2.1

1 by
This commit was manufactured by cvs2svn to create branch
1
# -*- python -*-
2
#
1779 by Mark Sapiro
Bump copyright dates.
3
# Copyright (C) 2001-2018 by the Free Software Foundation, Inc.
1 by
This commit was manufactured by cvs2svn to create branch
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 
749 by tkikuchi
FSF office has moved to 51 Franklin Street.
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1 by
This commit was manufactured by cvs2svn to create branch
18
19
"""Simple join-a-list email address.
20
21
Called by the wrapper, stdin is the mail message, and argv[1] is the name
22
of the target mailing list.
23
24
Errors are redirected to logs/errors.
25
"""
26
27
import sys
28
29
import paths
30
from Mailman import mm_cfg
31
from Mailman import Utils
32
from Mailman.i18n import _
33
from Mailman.Queue.sbcache import get_switchboard
34
from Mailman.Logging.Utils import LogStdErr
35
36
LogStdErr('error', 'join')
37
38
39

40
def main():
41
    try:
42
        listname = sys.argv[1]
43
    except IndexError:
44
        print >> sys.stderr, _('join script got no listname.')
45
        sys.exit(1)
46
    # Make sure the list exists
47
    if not Utils.list_exists(listname):
48
        print >> sys.stderr, _('join script, list not found: %(listname)s')
49
        sys.exit(1)
50
    # Immediately queue the message for the bounce/cmd qrunner to process.
51
    # The advantage to this approach is that messages should never get lost --
52
    # some MTAs have a hard limit to the time a filter prog can run.  Postfix
53
    # is a good example; if the limit is hit, the proc is SIGKILL'd giving us
54
    # no chance to save the message.
55
    cmdq = get_switchboard(mm_cfg.CMDQUEUE_DIR)
56
    cmdq.enqueue(sys.stdin.read(), listname=listname, tojoin=1, _plaintext=1)
57
58
59

60
if __name__ == '__main__':
61
    main()