smtp_direct.py is dead and gone.
[mailman.git] / src / mailman / pipeline / to_outgoing.py
blobef6908ab88bd7c4fa683b2eee3c8aa7086575f4f
1 # Copyright (C) 1998-2009 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
8 # any later version.
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18 """Re-queue the message to the outgoing queue.
20 This module is only for use by the IncomingRunner for delivering messages
21 posted to the list membership. Anything else that needs to go out to some
22 recipient should just be placed in the out queue directly.
23 """
25 from __future__ import absolute_import, unicode_literals
27 __metaclass__ = type
28 __all__ = [
29 'ToOutgoing',
33 from lazr.config import as_boolean
34 from zope.interface import implements
36 from mailman.config import config
37 from mailman.i18n import _
38 from mailman.interfaces.handler import IHandler
39 from mailman.interfaces.mailinglist import Personalization
43 class ToOutgoing:
44 """Send the message to the outgoing queue."""
46 implements(IHandler)
48 name = 'to-outgoing'
49 description = _('Send the message to the outgoing queue.')
51 def process(self, mlist, msg, msgdata):
52 """See `IHandler`."""
53 interval = int(config.mta.verp_delivery_interval)
54 # Should we VERP this message? If personalization is enabled for this
55 # list and VERP_PERSONALIZED_DELIVERIES is true, then yes we VERP it.
56 # Also, if personalization is /not/ enabled, but
57 # VERP_DELIVERY_INTERVAL is set (and we've hit this interval), then
58 # again, this message should be VERPed. Otherwise, no.
60 # Note that the verp flag may already be set, e.g. by mailpasswds
61 # using VERP_PASSWORD_REMINDERS. Preserve any existing verp flag.
62 if 'verp' in msgdata:
63 pass
64 elif mlist.personalize <> Personalization.none:
65 if as_boolean(config.mta.verp_personalized_deliveries):
66 msgdata['verp'] = True
67 elif interval == 0:
68 # Never VERP
69 pass
70 elif interval == 1:
71 # VERP every time
72 msgdata['verp'] = True
73 else:
74 # VERP every `interval' number of times
75 msgdata['verp'] = (int(mlist.post_id) % interval == 0)
76 # And now drop the message in qfiles/out
77 config.switchboards['out'].enqueue(
78 msg, msgdata, listname=mlist.fqdn_listname)