mirror of
https://github.com/fergalmoran/fsai-api.git
synced 2025-12-22 09:18:39 +00:00
20 lines
594 B
Python
20 lines
594 B
Python
import os
|
|
|
|
from flask import render_template
|
|
from flask_mail import Message
|
|
|
|
from app import create_app
|
|
from app import mail
|
|
|
|
|
|
def send_email(recipient, subject, template, **kwargs):
|
|
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
|
|
with app.app_context():
|
|
msg = Message(
|
|
app.config['EMAIL_SUBJECT_PREFIX'] + ' ' + subject,
|
|
sender=app.config['EMAIL_SENDER'],
|
|
recipients=[recipient])
|
|
msg.body = render_template(template + '.txt', **kwargs)
|
|
msg.html = render_template(template + '.html', **kwargs)
|
|
mail.send(msg)
|