Zakladni mailing
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
from typing import Any
|
||||
from fastapi_mail import MessageSchema, MessageType
|
||||
from pydantic import EmailStr
|
||||
|
||||
|
||||
class Email(MessageSchema):
|
||||
template: str
|
||||
|
||||
def __init__(self, to: list[EmailStr | str], subject: str, template: str, template_variables: dict, **data: Any) -> None:
|
||||
data['subtype'] = MessageType.html
|
||||
data['recipients'] = to
|
||||
data['template'] = template
|
||||
data['template_body'] = template_variables
|
||||
data['subject'] = subject + " | Polétání.cz"
|
||||
super().__init__(**data)
|
||||
|
||||
|
||||
class ContactFormEmail(Email):
|
||||
def __init__(self, email_from: str, content: str):
|
||||
super().__init__(
|
||||
to=["michal@kvacek.cz"],
|
||||
reply_to=[email_from],
|
||||
subject="Zpráva z kontaktního formuláře",
|
||||
template="contact_form.html",
|
||||
template_variables={
|
||||
"content": content,
|
||||
"email_from": email_from
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class WelcomeEmail(Email):
|
||||
def __init__(self, to: list[EmailStr | str]):
|
||||
super().__init__(
|
||||
to=to,
|
||||
subject="Vítej",
|
||||
template="welcome.html",
|
||||
template_variables={}
|
||||
)
|
||||
|
||||
|
||||
class ResetPasswordEmail(Email):
|
||||
def __init__(self, to: list[EmailStr | str], template_variables: dict):
|
||||
super().__init__(
|
||||
to=to,
|
||||
subject="Reset hesla",
|
||||
template="reset_password.html",
|
||||
template_variables=template_variables
|
||||
)
|
||||
@@ -1,39 +0,0 @@
|
||||
class Email:
|
||||
def __init__(self, subject: str, to: str, template: str, template_variables: dict):
|
||||
self.subject = subject + " | Polétání.cz"
|
||||
self.to = to
|
||||
self.template = template
|
||||
self.template_variables = template_variables
|
||||
|
||||
def get_template_content(self) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
class ContactFormEmail(Email):
|
||||
def __init__(self, template_variables: dict):
|
||||
super().__init__(
|
||||
subject="Zpráva z kontaktního formuláře",
|
||||
to="michal@kvacek.cz",
|
||||
template="contact_form.html",
|
||||
template_variables=template_variables
|
||||
)
|
||||
|
||||
|
||||
class WelcomeEmail(Email):
|
||||
def __init__(self, to: str, template_variables: dict):
|
||||
super().__init__(
|
||||
subject="Vítej",
|
||||
to=to,
|
||||
template="welcome.html",
|
||||
template_variables=template_variables
|
||||
)
|
||||
|
||||
|
||||
class ResetPasswordEmail(Email):
|
||||
def __init__(self, to: str, template_variables: dict):
|
||||
super().__init__(
|
||||
subject="Reset hesla",
|
||||
to=to,
|
||||
template="reset_password.html",
|
||||
template_variables=template_variables
|
||||
)
|
||||
Reference in New Issue
Block a user