Добавлена работа с email

This commit is contained in:
2021-07-14 13:35:34 +03:00
parent af5478994c
commit 729012ecca
7 changed files with 76 additions and 5 deletions

25
dyxless/mails.py Normal file
View File

@@ -0,0 +1,25 @@
from flask import Blueprint
from flask_mail import Message
from . import mail
from .decorators import async_work
mails = Blueprint("mails", __name__)
def prepare_msg(subject, sender, recipients, text_body, html_body):
msg = Message(subject, sender=sender, recipients=recipients)
msg.body = text_body
msg.html = html_body
return msg
@async_work
def send_async_email(subject, sender, recipients, text_body, html_body):
msg = prepare_msg(subject, sender, recipients, text_body, html_body)
mail.send(msg)
def send_mail(subject, sender, recipients, text_body, html_body):
msg = prepare_msg(subject, sender, recipients, text_body, html_body)
mail.send(msg)