diff --git a/server/notify.py b/server/notify.py index d28edc0..f2cf8d6 100644 --- a/server/notify.py +++ b/server/notify.py @@ -12,6 +12,7 @@ number and a deep link, not the work-package contents. """ import os import smtplib +import socket import uuid import logging from email.message import EmailMessage @@ -107,7 +108,13 @@ def send_email(s: dict, to_addr: str, subject: str, body: str) -> None: port = int(s.get("smtp_port") or 587) user = s.get("smtp_username") or "" pw = os.getenv("SMTP_PASSWORD", "") - with smtplib.SMTP(host, port, timeout=15) as srv: + # local_hostname pins the EHLO name. Without it smtplib calls getfqdn() on + # EVERY connect, and that reverse-DNS lookup stalls ~5s per send whenever DNS + # is slow or unreachable - sends are sequential background tasks, so a batch + # of notifications trickled out one per five seconds. gethostname() never + # touches the network. Found 2026-08-20 when the office link dropped. + with smtplib.SMTP(host, port, timeout=15, + local_hostname=(socket.gethostname() or "wp-suite")) as srv: if s.get("smtp_use_tls", True): srv.starttls() if user: