-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from crescents720/login_issue
speed up sending reset email
- Loading branch information
Showing
1 changed file
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |