From baa763c784642c1a4723897ea3d0c52e1425fff0 Mon Sep 17 00:00:00 2001 From: Evili del Rio Date: Fri, 4 Dec 2020 11:49:20 +0100 Subject: [PATCH] Add support for standard STARTTLS on port 143 (RFC 2595). Signed-off-by: Evili del Rio --- helpdesk/email.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helpdesk/email.py b/helpdesk/email.py index 5fd68a86..c0000d0c 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -101,6 +101,10 @@ def process_email(quiet=False): def pop3_sync(q, logger, server): server.getwelcome() + try: + server.stls() + except Exception: + logger.warning("POP3 StartTLS failed or unsupported. Connection will be unencrypted.") server.user(q.email_box_user or settings.QUEUE_EMAIL_BOX_USER) server.pass_(q.email_box_pass or settings.QUEUE_EMAIL_BOX_PASSWORD) @@ -138,6 +142,10 @@ def pop3_sync(q, logger, server): def imap_sync(q, logger, server): try: + try: + server.starttl() + except Exception: + logger.warning("IMAP4 StartTLS unsupported or failed. Connection will be unencrypted.") server.login(q.email_box_user or settings.QUEUE_EMAIL_BOX_USER, q.email_box_pass or