Forums

flask_mail not sending emails

I'm having some trouble when sending emails from my webapp that I'm hoping you can help me with. I do not encounter these errors on my development machine. I can send emails and they are received with no issues in the same way, using the same credentials.

:

I've narrowed this down to the fact the email is sent using current_app.executor.submit (ie as a background task). When I remove that and send as part of the function, the mail gets sent no problem. Does anyone know how I can do this and not have to wait for the email to be sent before rendering the page?

Unfortunately website code on PythonAnywhere runs single-threaded, so you'll need to do it in the view. It shouldn't take that long, though -- sending an email would normally take tenths of a second a most.