diff --git a/chatmaild/src/chatmaild/filtermail.py b/chatmaild/src/chatmaild/filtermail.py index 859b628d..02331758 100644 --- a/chatmaild/src/chatmaild/filtermail.py +++ b/chatmaild/src/chatmaild/filtermail.py @@ -37,6 +37,7 @@ def check_encrypted(message): class BeforeQueueHandler: def __init__(self): self.send_rate_limiter = SendRateLimiter() + self.smtp = SMTPClient("localhost", "10025") async def handle_MAIL(self, server, session, envelope, address, mail_options): logging.info(f"handle_MAIL from {address}") @@ -56,8 +57,7 @@ class BeforeQueueHandler: if error: return error logging.info("re-injecting the mail that passed checks") - client = SMTPClient("localhost", "10025") - client.sendmail(envelope.mail_from, envelope.rcpt_tos, envelope.content) + self.smtp.sendmail(envelope.mail_from, envelope.rcpt_tos, envelope.content) return "250 OK"