def send_email_celery(to, subject, template, countdown=None, **kwargs):
"""Send async email using Celery.
"""
app = current_app._get_current_object()
msg = Message(app.config['APP_MAIL_SUBJECT_PREFIX'] + ' ' + subject,
sender=app.config['APP_MAIL_SENDER'], recipients=[to])
msg.body = render_template(template + '.txt', **kwargs)
msg.html = render_template(template + '.html', **kwargs)
send_celery_async_email.apply_async(args=[msg], countdown=countdown)
评论列表
文章目录