Skip to content

Commit

Permalink
Merge pull request #14 from crescents720/login_issue
Browse files Browse the repository at this point in the history
speed up sending reset email
  • Loading branch information
daphnelyq authored May 5, 2020
2 parents c217d3f + a4b2c46 commit d601735
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/email.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
from threading import Thread
from flask import current_app, render_template
from flask_mail import Message

from app import mail
from app import mail, app


def send_async_mail(app, msg):
with app.app_context():
mail.send(msg)


def send_reset_password_mail(user, token):
msg = Message("[COVID Coach] Reset Your Password",
sender=current_app.config['MAIL_USERNAME'],
recipients=[user.email],
html=render_template('reset_password_mail.html', user=user, token=token))
mail.send(msg)
# mail.send(msg)
Thread(target=send_async_mail, args=(app, msg)).start()

0 comments on commit d601735

Please sign in to comment.