]> git.datanom.net - flask-test.git/blob - app/emails.py
final
[flask-test.git] / app / emails.py
1 from flask_mail import Message
2 from app import mail
3 from app import app
4 from flask import render_template
5 from config import ADMINS
6 from .decorators import async
7
8 @async
9 def send_async_email(app, msg):
10 with app.app_context():
11 mail.send(msg)
12
13 def 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
19 def 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.057901 seconds and 6 git commands to generate.