From 6fb3198a41fb8933c8ec2ceb56012e9ac25c16e9 Mon Sep 17 00:00:00 2001 From: "Sergey G. Brester" Date: Thu, 11 Aug 2022 18:27:03 +0200 Subject: [PATCH] attempt to fix action for 2.x self.host cannot be supplied to SMTP because it can contain port (but `connect` takes place few lines below) --- config/action.d/smtp.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config/action.d/smtp.py b/config/action.d/smtp.py index 3ad9b159..c3ef9936 100644 --- a/config/action.d/smtp.py +++ b/config/action.d/smtp.py @@ -157,15 +157,16 @@ class SMTPAction(ActionBase): msg['To'] = self.toaddr msg['Date'] = formatdate() - smtp = smtplib.SMTP(self.host) + smtp = smtplib.SMTP() try: + r = smtp.connect(self.host) self._logSys.debug("Connected to SMTP '%s', response: %i: %s", - self.host, *smtp.connect(self.host)) + self.host, *r) if self.ssl: # pragma: no cover - tls_result = smtp.starttls()[0]; - if tls_result != 220: # pragma: no cover - raise Exception("Failed to starttls() on '%s': %s" % (self.host, tls_result)) + r = smtp.starttls()[0]; + if r != 220: # pragma: no cover + raise Exception("Failed to starttls() on '%s': %s" % (self.host, r)) if self.user and self.password: # pragma: no cover (ATM no tests covering that) smtp.login(self.user, self.password)