mirror of
https://github.com/Llloooggg/Dyxless.git
synced 2026-03-06 18:56:24 +03:00
39 lines
799 B
Python
39 lines
799 B
Python
from flask import Blueprint, render_template
|
|
from flask_mail import Message
|
|
|
|
from . import app, mail
|
|
from .decorators import async_work
|
|
|
|
mails = Blueprint("mails", __name__)
|
|
|
|
|
|
def prepare_msg(subject, recipients, body, html, sender):
|
|
msg = Message(subject, sender=sender, recipients=recipients)
|
|
msg.body = body
|
|
msg.html = html
|
|
return msg
|
|
|
|
|
|
@async_work
|
|
def send_async_email(
|
|
subject,
|
|
recipients,
|
|
body=None,
|
|
html=None,
|
|
sender=app.config["APP_EMAIL"],
|
|
):
|
|
msg = prepare_msg(subject, recipients, body, html, sender)
|
|
with app.app_context():
|
|
mail.send(msg)
|
|
|
|
|
|
def send_mail(
|
|
subject,
|
|
recipients,
|
|
body=None,
|
|
html=None,
|
|
sender=app.config["APP_EMAIL"],
|
|
):
|
|
msg = prepare_msg(subject, recipients, body, html, sender)
|
|
mail.send(msg)
|