How to send emails in background in python webapplication with flask framework? -


i need sent emails large number of recipients attachments web application after completing event. want run in background in order not affect main application processes. how implement this?

miguel grinberg gives complete example of in flask mega tutorial.

basically can push mail sending thread.

from threading import thread app import app  def send_async_email(app, msg):     app.app_context():         mail.send(msg)  def send_email(subject, sender, recipients, text_body, html_body):     msg = message(subject, sender=sender, recipients=recipients)     msg.body = text_body     msg.html = html_body     thr = thread(target=send_async_email, args=[app, msg])     thr.start() 

Comments

Popular posts from this blog

json - Zend error Connection -

javascript - Trigger mouseenter when an animated element touches mouse -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -