mirror of
https://github.com/Llloooggg/Dyxless.git
synced 2026-03-06 10:46:24 +03:00
Добавлена работа с email
This commit is contained in:
25
dyxless/mails.py
Normal file
25
dyxless/mails.py
Normal 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)
|
||||
Reference in New Issue
Block a user