summaryrefslogtreecommitdiff
path: root/src/mailman/runners/lmtp.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/runners/lmtp.py')
-rw-r--r--src/mailman/runners/lmtp.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py
index 7560fd962..85730bb7d 100644
--- a/src/mailman/runners/lmtp.py
+++ b/src/mailman/runners/lmtp.py
@@ -34,9 +34,6 @@ so that the peer mail server can provide better diagnostics.
http://www.faqs.org/rfcs/rfc2033.html
"""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'LMTPRunner',
]
@@ -48,8 +45,6 @@ import logging
import asyncore
from email.utils import parseaddr
-from zope.component import getUtility
-
from mailman.config import config
from mailman.core.runner import Runner
from mailman.database.transaction import transactional
@@ -57,6 +52,7 @@ from mailman.email.message import Message
from mailman.interfaces.listmanager import IListManager
from mailman.utilities.datetime import now
from mailman.utilities.email import add_message_hash
+from zope.component import getUtility
elog = logging.getLogger('mailman.error')
@@ -91,15 +87,15 @@ SUBADDRESS_QUEUES = dict(
)
DASH = '-'
-CRLF = b'\r\n'
-ERR_451 = b'451 Requested action aborted: error in processing'
-ERR_501 = b'501 Message has defects'
-ERR_502 = b'502 Error: command HELO not implemented'
-ERR_550 = b'550 Requested action not taken: mailbox unavailable'
-ERR_550_MID = b'550 No Message-ID header provided'
+CRLF = '\r\n'
+ERR_451 = '451 Requested action aborted: error in processing'
+ERR_501 = '501 Message has defects'
+ERR_502 = '502 Error: command HELO not implemented'
+ERR_550 = '550 Requested action not taken: mailbox unavailable'
+ERR_550_MID = '550 No Message-ID header provided'
# XXX Blech
-smtpd.__version__ = b'Python LMTP runner 1.0'
+smtpd.__version__ = 'Python LMTP runner 1.0'
@@ -147,6 +143,10 @@ class Channel(smtpd.SMTPChannel):
"""HELO is not a valid LMTP command."""
self.push(ERR_502)
+ ## def push(self, arg):
+ ## import pdb; pdb.set_trace()
+ ## return super().push(arg)
+
class LMTPRunner(Runner, smtpd.SMTPServer):
@@ -202,18 +202,19 @@ class LMTPRunner(Runner, smtpd.SMTPServer):
for to in rcpttos:
try:
to = parseaddr(to)[1].lower()
- listname, subaddress, domain = split_recipient(to)
+ local, subaddress, domain = split_recipient(to)
slog.debug('%s to: %s, list: %s, sub: %s, dom: %s',
- message_id, to, listname, subaddress, domain)
- listname += '@' + domain
+ message_id, to, local, subaddress, domain)
+ listname = '{}@{}'.format(local, domain)
if listname not in listnames:
status.append(ERR_550)
continue
+ listid = '{}.{}'.format(local, domain)
# The recipient is a valid mailing list. Find the subaddress
# if there is one, and set things up to enqueue to the proper
# queue.
queue = None
- msgdata = dict(listname=listname,
+ msgdata = dict(listid=listid,
original_size=msg.original_size,
received_time=received_time)
canonical_subaddress = SUBADDRESS_NAMES.get(subaddress)
@@ -243,7 +244,7 @@ class LMTPRunner(Runner, smtpd.SMTPServer):
config.switchboards[queue].enqueue(msg, msgdata)
slog.debug('%s subaddress: %s, queue: %s',
message_id, canonical_subaddress, queue)
- status.append(b'250 Ok')
+ status.append('250 Ok')
except Exception:
slog.exception('Queue detection: %s', msg['message-id'])
config.db.abort()