Skip to content

Commit 758f4fb

Browse files
smtp_ssl
1 parent 2516159 commit 758f4fb

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

auth_backend/utils/smtp.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def send_confirmation_email(to_addr, link):
4040
img.add_header('Content-ID', '<header>')
4141
message.attach(img)
4242

43-
with smtplib.SMTP(settings.SMTP_HOST, settings.SMTP_PORT) as smtp:
44-
smtp.starttls()
43+
with smtplib.SMTP_SSL(settings.SMTP_HOST, 465) as smtp:
4544
smtp.login(settings.EMAIL, settings.EMAIL_PASS)
4645
smtp.sendmail(settings.EMAIL, to_addr, message.as_string())
4746

@@ -76,8 +75,7 @@ def send_reset_email(to_addr, link):
7675
img.add_header('Content-ID', '<header>')
7776
message.attach(img)
7877

79-
with smtplib.SMTP(settings.SMTP_HOST, settings.SMTP_PORT) as smtp:
80-
smtp.starttls()
78+
with smtplib.SMTP_SSL(settings.SMTP_HOST, 465) as smtp:
8179
smtp.login(settings.EMAIL, settings.EMAIL_PASS)
8280
smtp.sendmail(settings.EMAIL, to_addr, message.as_string())
8381

@@ -112,12 +110,10 @@ def send_change_password_confirmation(to_addr, link):
112110
img.add_header('Content-ID', '<header>')
113111
message.attach(img)
114112

115-
with smtplib.SMTP(settings.SMTP_HOST, settings.SMTP_PORT) as smtp:
116-
smtp.starttls()
113+
with smtplib.SMTP_SSL(settings.SMTP_HOST, 465) as smtp:
117114
smtp.login(settings.EMAIL, settings.EMAIL_PASS)
118115
smtp.sendmail(settings.EMAIL, to_addr, message.as_string())
119116

120-
121117
@retry(
122118
stop_max_attempt_number=settings.MAX_RETRIES,
123119
stop_max_delay=settings.STOP_MAX_DELAY,
@@ -147,7 +143,6 @@ def send_changes_password_notification(to_addr):
147143
img.add_header('Content-ID', '<header>')
148144
message.attach(img)
149145

150-
with smtplib.SMTP(settings.SMTP_HOST, settings.SMTP_PORT) as smtp:
151-
smtp.starttls()
146+
with smtplib.SMTP_SSL(settings.SMTP_HOST, 465) as smtp:
152147
smtp.login(settings.EMAIL, settings.EMAIL_PASS)
153148
smtp.sendmail(settings.EMAIL, to_addr, message.as_string())

0 commit comments

Comments
 (0)