Fixed API changes in SMTPChannel

- Legacy-Id: 16329
This commit is contained in:
Henrik Levkowetz 2019-06-28 20:52:15 +00:00
parent 1e86ccb4ee
commit ea109f2b1b

View file

@ -1,7 +1,11 @@
# Copyright The IETF Trust 2014-2019, All Rights Reserved
import smtpd
import threading
import asyncore
import debug # pyflakes:ignore
class AsyncCoreLoopThread(object):
def wrap_loop(self, exit_condition, timeout=1.0, use_poll=False, map=None):
@ -27,18 +31,22 @@ class AsyncCoreLoopThread(object):
class SMTPTestChannel(smtpd.SMTPChannel):
# mail_options = ['BODY=8BITMIME', 'SMTPUTF8']
def smtp_RCPT(self, arg):
if not self._SMTPChannel__mailfrom:
self.rcpt_options = []
if not self.mailfrom:
self.push('503 Error: need MAIL command')
return
address = self._SMTPChannel__getaddr('TO:', arg) if arg else None
arg = self._strip_command_keyword('TO:', arg)
address, params = self._getaddr(arg)
if not address:
self.push('501 Syntax: RCPT TO: <address>')
return
if "poison" in address:
self.push('550 Error: Not touching that')
return
self._SMTPChannel__rcpttos.append(address)
self.rcpttos.append(address)
self.push('250 Ok')
class SMTPTestServer(smtpd.SMTPServer):
@ -57,7 +65,7 @@ class SMTPTestServer(smtpd.SMTPServer):
#channel = SMTPTestChannel(self, conn, addr)
SMTPTestChannel(self, conn, addr)
def process_message(self, peer, mailfrom, rcpttos, data):
def process_message(self, peer, mailfrom, rcpttos, data, mail_options=[], rcpt_options=[]):
self.inbox.append(data)