mirror of https://github.com/fail2ban/fail2ban
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)pull/3268/head
parent
6a1da5e164
commit
6fb3198a41
|
@ -157,15 +157,16 @@ class SMTPAction(ActionBase):
|
||||||
msg['To'] = self.toaddr
|
msg['To'] = self.toaddr
|
||||||
msg['Date'] = formatdate()
|
msg['Date'] = formatdate()
|
||||||
|
|
||||||
smtp = smtplib.SMTP(self.host)
|
smtp = smtplib.SMTP()
|
||||||
try:
|
try:
|
||||||
|
r = smtp.connect(self.host)
|
||||||
self._logSys.debug("Connected to SMTP '%s', response: %i: %s",
|
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
|
if self.ssl: # pragma: no cover
|
||||||
tls_result = smtp.starttls()[0];
|
r = smtp.starttls()[0];
|
||||||
if tls_result != 220: # pragma: no cover
|
if r != 220: # pragma: no cover
|
||||||
raise Exception("Failed to starttls() on '%s': %s" % (self.host, tls_result))
|
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)
|
if self.user and self.password: # pragma: no cover (ATM no tests covering that)
|
||||||
smtp.login(self.user, self.password)
|
smtp.login(self.user, self.password)
|
||||||
|
|
Loading…
Reference in New Issue