mirror of
https://github.com/chatmail/relay.git
synced 2026-05-20 04:48:06 +00:00
filtermail: use single SMTP connection to reinject mails
This commit is contained in:
@@ -143,12 +143,18 @@ def check_encrypted(message):
|
|||||||
|
|
||||||
async def asyncmain_beforequeue(config):
|
async def asyncmain_beforequeue(config):
|
||||||
port = config.filtermail_smtp_port
|
port = config.filtermail_smtp_port
|
||||||
Controller(BeforeQueueHandler(config), hostname="127.0.0.1", port=port).start()
|
smtp_client = SMTPClient("localhost", config.postfix_reinject_port)
|
||||||
|
Controller(
|
||||||
|
BeforeQueueHandler(config, smtp_client=smtp_client),
|
||||||
|
hostname="127.0.0.1",
|
||||||
|
port=port,
|
||||||
|
).start()
|
||||||
|
|
||||||
|
|
||||||
class BeforeQueueHandler:
|
class BeforeQueueHandler:
|
||||||
def __init__(self, config):
|
def __init__(self, config, smtp_client):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.smtp_client = smtp_client
|
||||||
self.send_rate_limiter = SendRateLimiter()
|
self.send_rate_limiter = SendRateLimiter()
|
||||||
|
|
||||||
async def handle_MAIL(self, server, session, envelope, address, mail_options):
|
async def handle_MAIL(self, server, session, envelope, address, mail_options):
|
||||||
@@ -170,8 +176,9 @@ class BeforeQueueHandler:
|
|||||||
if error:
|
if error:
|
||||||
return error
|
return error
|
||||||
logging.info("re-injecting the mail that passed checks")
|
logging.info("re-injecting the mail that passed checks")
|
||||||
client = SMTPClient("localhost", self.config.postfix_reinject_port)
|
self.smtp_client.sendmail(
|
||||||
client.sendmail(envelope.mail_from, envelope.rcpt_tos, envelope.content)
|
envelope.mail_from, envelope.rcpt_tos, envelope.content
|
||||||
|
)
|
||||||
return "250 OK"
|
return "250 OK"
|
||||||
|
|
||||||
def check_DATA(self, envelope):
|
def check_DATA(self, envelope):
|
||||||
|
|||||||
Reference in New Issue
Block a user