Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap from insecure SMTP to secure SMTP #675

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/iris/vendors/iris_smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from gevent import sleep
from iris.constants import EMAIL_SUPPORT, IM_SUPPORT
from smtplib import SMTP
from smtplib import SMTP_SSL
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formatdate
Expand Down Expand Up @@ -139,8 +139,7 @@ def send_email(self, message, customizations=None):
else:
for mx in self.mx_sorted:
try:
smtp = SMTP(timeout=self.smtp_timeout)
smtp.connect(mx[1], self.config.get('port', 25))
smtp = SMTP_SSL(mx[1], port=self.config.get('port', 25), timeout=self.smtp_timeout)
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
Expand All @@ -167,7 +166,7 @@ def send_email(self, message, customizations=None):
# giving up
for mx in self.mx_sorted:
try:
smtp = SMTP(timeout=self.smtp_timeout)
smtp = SMTP_SSL(mx[1], port=self.config.get('port', 25), timeout=self.smtp_timeout)
smtp.connect(mx[1], 25)
conn = smtp
self.last_conn = conn
Expand Down