Zakladni mailing
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from fastapi_mail import ConnectionConfig, FastMail
|
||||
from config import SMTP_USERNAME, SMTP_PASSWORD, SMTP_PORT, SMTP_HOST
|
||||
from emails.emails import Email
|
||||
|
||||
|
||||
class Mailer:
|
||||
def __init__(self):
|
||||
self.conf = ConnectionConfig(
|
||||
MAIL_USERNAME=SMTP_USERNAME,
|
||||
MAIL_PASSWORD=SMTP_PASSWORD,
|
||||
MAIL_FROM_NAME="Polétání",
|
||||
MAIL_PORT=SMTP_PORT,
|
||||
MAIL_SERVER=SMTP_HOST,
|
||||
MAIL_STARTTLS=False,
|
||||
MAIL_SSL_TLS=True,
|
||||
USE_CREDENTIALS=True,
|
||||
TEMPLATE_FOLDER='/app/src/emails/templates/html'
|
||||
)
|
||||
|
||||
async def send(self, mail: Email):
|
||||
fm = FastMail(self.conf)
|
||||
await fm.send_message(mail, mail.template)
|
||||
Reference in New Issue
Block a user