Fix send email

This commit is contained in:
2026-02-06 19:50:48 +03:00
parent 098d60f0a7
commit c1a51903ef
+2 -4
View File
@@ -36,11 +36,9 @@ class EmailClient:
msg.attach(MIMEText(body, "plain", "utf-8")) msg.attach(MIMEText(body, "plain", "utf-8"))
with smtplib.SMTP_SSL(settings.SMTP_SERVER, settings.SMTP_PORT) as smtp: with smtplib.SMTP_SSL(settings.SMTP_SERVER, settings.SMTP_PORT) as smtp:
if not settings.MODE == "DEV": smtp.login(settings.SMTP_EMAIL, settings.SMTP_PASS)
smtp.starttls()
smtp.login(settings.SMTP_EMAIL, settings.SMTP_PASS)
smtp.send_message(msg) smtp.send_message(msg)
log.info("Email sent successfully", extra={"to": to, "subject": subject}) log.info("Email sent successfully %s", to, extra={"to": to, "subject": subject})
except Exception as e: except Exception as e:
log.error(f"Failed to send email: {str(e)}", extra={"to": to, "subject": subject}) log.error(f"Failed to send email: {str(e)}", extra={"to": to, "subject": subject})
raise e raise e