123 lines
3.1 KiB
Python
123 lines
3.1 KiB
Python
from email.message import EmailMessage
|
|
|
|
from pydantic import EmailStr
|
|
|
|
from app.config import settings
|
|
|
|
|
|
def create_registration_confirmation_template(
|
|
username: str, email_to: EmailStr, confirmation_link: str, confirmation_code: str
|
|
):
|
|
email = EmailMessage()
|
|
|
|
email["Subject"] = "Подтверждение регистрации"
|
|
email["From"] = settings.SMTP_USER
|
|
email["To"] = email_to
|
|
|
|
email.set_content(
|
|
f"""
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="style.css">
|
|
<title>Pegr</title>
|
|
</head>
|
|
<body>
|
|
<body style="
|
|
width:99%;
|
|
height:99%;
|
|
|
|
display: flex;
|
|
flex-direction:column;
|
|
align-items: center;
|
|
|
|
background-color:#101010;
|
|
|
|
font-family: 'Comfortaa';
|
|
src: url('./fonts/Comfortaa-VariableFont_wght.ttf') format('truetype');
|
|
font-weight: 1 1000; /* Объявляем диапазон веса шрифта */
|
|
font-style: normal;
|
|
font-stretch: normal;">
|
|
|
|
<div style="display: flex;
|
|
flex-direction: column;
|
|
justify-content:space-around;
|
|
align-items: center;
|
|
|
|
height:500px;
|
|
aspect-ratio: 1 / 1.44;
|
|
|
|
border: 1px solid transparent;
|
|
background:
|
|
linear-gradient(#101010, #101010) padding-box,
|
|
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
|
border-radius: 15px;
|
|
">
|
|
|
|
<h1 style=" color:white;">Код подтверждения для {username}</h1>
|
|
<div style="border: 1px solid transparent;
|
|
background:
|
|
linear-gradient(#101010, #101010) padding-box,
|
|
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
|
border-radius: 15px;">
|
|
|
|
<h2 style="color:white;
|
|
padding:0 5px 0 5px;">{confirmation_code}</h2>
|
|
</div>
|
|
|
|
<h1 style="color:white;">или</h1>
|
|
|
|
<a href="{confirmation_link}" style="border: 1px solid transparent;
|
|
background:
|
|
linear-gradient(#101010, #101010) padding-box,
|
|
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
|
border-radius: 15px;
|
|
text-decoration: none;">
|
|
|
|
<h2 style="color: white;
|
|
padding:0 5px 0 5px;">перейдите по ссылке</h2>
|
|
</a>
|
|
</div>
|
|
</body>
|
|
</body>
|
|
</html>
|
|
""",
|
|
subtype="html",
|
|
)
|
|
return email
|
|
|
|
|
|
def create_data_change_confirmation_email(username: str, email_to: EmailStr, confirmation_code: str):
|
|
email = EmailMessage()
|
|
|
|
email["Subject"] = "Подтверждение изменения данных"
|
|
email["From"] = settings.SMTP_USER
|
|
email["To"] = email_to
|
|
|
|
email.set_content(
|
|
f"""
|
|
<h1>{username}, лови аптечку</h1>
|
|
{confirmation_code}
|
|
""",
|
|
subtype="html",
|
|
)
|
|
return email
|
|
|
|
|
|
def create_data_change_email(username: str, email_to: EmailStr):
|
|
email = EmailMessage()
|
|
|
|
email["Subject"] = "Изменение данных"
|
|
email["From"] = settings.SMTP_USER
|
|
email["To"] = email_to
|
|
|
|
email.set_content(
|
|
f"""
|
|
<h1>{username}, данные менял?</h1>
|
|
Вот то-то и оно.
|
|
""",
|
|
subtype="html",
|
|
)
|
|
return email
|