Skip to content

Commit

Permalink
send_user_email: check if MAIL_AUTH_PASSWD exist and make login optional
Browse files Browse the repository at this point in the history
  • Loading branch information
nobohan committed Jun 3, 2022
1 parent da233f7 commit 9b5c656
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions backend/gncitizen/utils/mail_check.py
Expand Up @@ -48,10 +48,13 @@ def send_user_email(
server.ehlo()
if current_app.config["MAIL"]["MAIL_STARTTLS"]:
server.starttls()
server.login(
str(current_app.config["MAIL"]["MAIL_AUTH_LOGIN"]),
str(current_app.config["MAIL"]["MAIL_AUTH_PASSWD"]),
)

if current_app.config["MAIL"]["MAIL_AUTH_PASSWD"]:
server.login(
str(current_app.config["MAIL"]["MAIL_AUTH_LOGIN"]),
str(current_app.config["MAIL"]["MAIL_AUTH_PASSWD"]),
)

server.sendmail(
current_app.config["MAIL"]["MAIL_AUTH_LOGIN"],
to,
Expand Down Expand Up @@ -104,10 +107,13 @@ def confirm_user_email(newuser):
server.ehlo()
if current_app.config["MAIL"]["MAIL_STARTTLS"]:
server.starttls()
server.login(
str(current_app.config["MAIL"]["MAIL_AUTH_LOGIN"]),
str(current_app.config["MAIL"]["MAIL_AUTH_PASSWD"]),
)

if current_app.config["MAIL"]["MAIL_AUTH_PASSWD"]:
server.login(
str(current_app.config["MAIL"]["MAIL_AUTH_LOGIN"]),
str(current_app.config["MAIL"]["MAIL_AUTH_PASSWD"]),
)

server.sendmail(
current_app.config["CONFIRM_EMAIL"]["FROM"], newuser.email, msg.as_string()
)
Expand Down

0 comments on commit 9b5c656

Please sign in to comment.