]> git.datanom.net - flask-test.git/blame - app/emails.py
final
[flask-test.git] / app / emails.py
CommitLineData
163c4d87
MR
1from flask_mail import Message
2from app import mail
3from app import app
4from flask import render_template
5from config import ADMINS
6from .decorators import async
7
8@async
9def send_async_email(app, msg):
10 with app.app_context():
11 mail.send(msg)
12
13def send_email(subject, sender, recipients, text_body, html_body):
14 msg = Message(subject, sender=sender, recipients=recipients)
15 msg.body = text_body
16 msg.html = html_body
17 send_async_email(app, msg)
18
19def follower_notification(followed, follower):
20 send_email("[WPP] %s is now following you!" % follower.nickname,
21 ADMINS[0],
22 [followed.email],
23 render_template("follower_email.txt",
24 user=followed, follower=follower),
25 render_template("follower_email.html",
26 user=followed, follower=follower))
27
This page took 0.030238 seconds and 5 git commands to generate.