Migrating from Flask-Mail - Coroutine never awaited #49
-
Hello, I had flask-mail setup and working but I’m trying to migrate to flask-mailing. I’ve got a question about how I use this when I have my email function in a different file. For example: jobs.py
views.py
This type of config that used to work for flask-mail now results in the error:
Could you help me understand how this kind of setup would work with flask-mailing please? |
Beta Was this translation helpful? Give feedback.
Answered by
marktennyson
Jan 28, 2023
Replies: 1 comment
-
Change the view function (I have checked only one scenario). You need to use asynchronous view function because coroutine function must be awaited. @auth.route('/register', methods=['GET', 'POST'])
async def register():
form = RegisterUserForm()
if form.validate_on_submit():
user = User.create(
username=form.data['username'],
email=form.data['email'],
password=form.data['password'],
remote_addr=request.remote_addr,
)
s = URLSafeSerializer(current_app.secret_key)
token = s.dumps(user.id)
await send_registration_email(user.id, token)
flash(
(
'Sent verification email to {email}'.format(
email=user.email
)
),
'success'
)
return redirect(url_for('home.index'))
return render_template('register.html', form=form) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
marktennyson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change the view function (I have checked only one scenario).
You need to use asynchronous view function because coroutine function must be awaited.