mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 19:04:18 +00:00
19 lines
534 B
Python
19 lines
534 B
Python
from flask import render_template
|
|
from flask_mail import Message
|
|
from . import mail
|
|
from .decorators import background
|
|
|
|
|
|
def create_message(recipient, subject, template, **kwargs):
|
|
msg = Message('[nopaque] {}'.format(subject), recipients=[recipient])
|
|
msg.body = render_template('{}.txt.j2'.format(template), **kwargs)
|
|
msg.html = render_template('{}.html.j2'.format(template), **kwargs)
|
|
return msg
|
|
|
|
|
|
@background
|
|
def send(msg, *args, **kwargs):
|
|
app = kwargs['app']
|
|
with app.app_context():
|
|
mail.send(msg)
|