Sending mail through office 365 with TLS fails.
- Dominant language
- Python
- Stars
- 845
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
Research direction
Start in src/iris/vendors/iris_smtp.py at the SMTP connection setup and review how the existing port, username, and password configuration is read. Define how TLS should be configured for Office 365 and verify that connections authenticate successfully when TLS is enabled without changing non-TLS behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100