Allow optional usage of the tls encryption for SMTPA

For local dev, a local SMTP server like mailhog is useful and allow to manually manage user creation
This commit is contained in:
Sébastien Campion 2024-01-27 19:16:53 +01:00 committed by ishaan-jaff
parent b39c53f64c
commit f7883bd3b9

View file

@ -1035,7 +1035,8 @@ async def send_email(sender_name, sender_email, receiver_email, subject, html):
print_verbose(f"SMTP Connection Init") print_verbose(f"SMTP Connection Init")
# Establish a secure connection with the SMTP server # Establish a secure connection with the SMTP server
with smtplib.SMTP(smtp_host, smtp_port) as server: with smtplib.SMTP(smtp_host, smtp_port) as server:
server.starttls() if os.getenv("SMTP_TLS", 'True') != "False":
server.starttls()
# Login to your email account # Login to your email account
server.login(smtp_username, smtp_password) server.login(smtp_username, smtp_password)