iris
iris copied to clipboard
Sending mail through office 365 with TLS fails.
Fails with the following error:
"/usr/lib/python2.7/smtplib.py", line 586, in login
raise SMTPException("SMTP AUTH extension not supported by server.")
SMTPException: SMTP AUTH extension not supported by server.
The quick and dirty fix is as below:
diff --git a/src/iris/vendors/iris_smtp.py b/src/iris/vendors/iris_smtp.py
index d833b43..4685abc 100644
--- a/src/iris/vendors/iris_smtp.py
+++ b/src/iris/vendors/iris_smtp.py
@@ -127,9 +127,12 @@ class iris_smtp(object):
conn = self.last_conn
else:
for mx in self.mx_sorted:
try:
smtp = SMTP(timeout=self.smtp_timeout)
smtp.connect(mx[1], self.config.get('port', 25))
+ smtp.ehlo()
+ smtp.starttls()
if self.config.get('username', None) is not None and self.config.get('password', None) is not None:
smtp.login(self.config.get('username', None), self.config.get('password', None))
conn = smtp
I assume the best fix would be to make it a configurable and then check if tls is required before doing starttls.
Please let me know if there is a preferred style and I'll submit a PR.
Your proposed fix sounds reasonable. As long as the new option is configurable and defaults to the current behavior, this sounds good to me.