From b0961404006b557ffcdc905294e4486bfaf217c2 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Thu, 12 Feb 2026 03:20:13 +0000
Subject: [PATCH] Support starttls
---
src/archrepobuild/notifications.py | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/archrepobuild/notifications.py b/src/archrepobuild/notifications.py
index 51cfd18..508c8bc 100644
--- a/src/archrepobuild/notifications.py
+++ b/src/archrepobuild/notifications.py
@@ -140,21 +140,24 @@
def _send_email(self, msg: MIMEMultipart) -> None:
"""Send email synchronously (called from executor)."""
+ smtp_class = smtplib.SMTP
+ use_starttls = False
+
if self.config.use_tls:
- context = ssl.create_default_context()
- with smtplib.SMTP_SSL(
- self.config.smtp_host,
- self.config.smtp_port,
- context=context,
- ) as server:
- if self.config.username and self.config.password:
- server.login(self.config.username, self.config.password)
- server.send_message(msg)
- else:
- with smtplib.SMTP(self.config.smtp_host, self.config.smtp_port) as server:
- if self.config.username and self.config.password:
- server.login(self.config.username, self.config.password)
- server.send_message(msg)
+ if self.config.smtp_port == 465:
+ smtp_class = smtplib.SMTP_SSL
+ else:
+ use_starttls = True
+
+ with smtp_class(self.config.smtp_host, self.config.smtp_port) as server:
+ if use_starttls:
+ context = ssl.create_default_context()
+ server.starttls(context=context)
+
+ if self.config.username and self.config.password:
+ server.login(self.config.username, self.config.password)
+
+ server.send_message(msg)
class WebhookBackend(NotificationBackend):
--
Gitblit v1.10.0