252 lines
6.2 KiB
Python
252 lines
6.2 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"""
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@200&display=swap" rel="stylesheet">
|
||
<title>Submiting</title>
|
||
</head>
|
||
<body style="margin: 0;padding: 0;">
|
||
<table cellpadding="10" cellspacing="0" width="100%" style="background-color: #101010;">
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td align="center">
|
||
<div style="
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content:space-around;
|
||
align-items: center;
|
||
text-align:center;
|
||
|
||
max-width:500px;
|
||
min-width:350px;
|
||
aspect-ratio: 1 / 1.34;
|
||
|
||
border: 1px solid transparent;
|
||
background:
|
||
linear-gradient(#101010, #101010) padding-box,
|
||
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||
border-radius: 12px;
|
||
|
||
font-family: comfortaa;
|
||
">
|
||
|
||
<h1 style="color:white; font-family: comfortaa;">Код подтверждения для сладкого {username}</h1>
|
||
|
||
<h2 style="
|
||
padding: 10px;
|
||
color: white;
|
||
border: 1px solid transparent;
|
||
background:
|
||
linear-gradient(#101010, #101010) padding-box,
|
||
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||
border-radius: 12px;
|
||
|
||
font-family: comfortaa;
|
||
">{confirmation_code}</h2>
|
||
|
||
<h1 style="color:white;">или</h1>
|
||
|
||
<a href="{confirmation_link}" style="
|
||
padding: 10px;
|
||
color: white;
|
||
border: 1px solid transparent;
|
||
background:
|
||
linear-gradient(#101010, #101010) padding-box,
|
||
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||
border-radius: 12px;
|
||
text-decoration: none;
|
||
|
||
font-family: comfortaa;
|
||
font-size:1.5em;
|
||
">перейдите по ссылке</a>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
</table>
|
||
</body>
|
||
</html>
|
||
""",
|
||
subtype="html",
|
||
)
|
||
return email
|
||
|
||
|
||
def create_data_change_confirmation_email(username: str, email_to: EmailStr, _: str, confirmation_code: str):
|
||
email = EmailMessage()
|
||
|
||
email["Subject"] = "Подтверждение изменения данных"
|
||
email["From"] = settings.SMTP_USER
|
||
email["To"] = email_to
|
||
|
||
email.set_content(
|
||
f"""
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@200&display=swap" rel="stylesheet">
|
||
<title>Submiting</title>
|
||
</head>
|
||
<body style="margin: 0;padding: 0;">
|
||
<table cellpadding="10" cellspacing="0" width="100%" style="background-color: #101010;">
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td align="center">
|
||
<div style="
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content:space-around;
|
||
align-items: center;
|
||
text-align:center;
|
||
|
||
max-width:500px;
|
||
min-width:350px;
|
||
aspect-ratio: 1 / 1.34;
|
||
|
||
border: 1px solid transparent;
|
||
background:
|
||
linear-gradient(#101010, #101010) padding-box,
|
||
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||
border-radius: 12px;
|
||
|
||
font-family: comfortaa;
|
||
">
|
||
|
||
<h1 style="color:white; font-family: comfortaa;">Код подтверждения для сладкого {username}</h1>
|
||
|
||
<h2 style="
|
||
padding: 10px;
|
||
color: white;
|
||
border: 1px solid transparent;
|
||
background:
|
||
linear-gradient(#101010, #101010) padding-box,
|
||
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||
border-radius: 12px;
|
||
|
||
font-family: comfortaa;
|
||
">{confirmation_code}</h2>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
</table>
|
||
</body>
|
||
</html>
|
||
""",
|
||
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"""
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@200&display=swap" rel="stylesheet">
|
||
<title>Submiting</title>
|
||
</head>
|
||
<body style="margin: 0;padding: 0;">
|
||
<table cellpadding="10" cellspacing="0" width="100%" style="background-color: #101010;">
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td align="center">
|
||
<div style="
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content:space-around;
|
||
align-items: center;
|
||
text-align:center;
|
||
|
||
max-width:500px;
|
||
min-width:350px;
|
||
aspect-ratio: 1 / 1.34;
|
||
|
||
border: 1px solid transparent;
|
||
background:
|
||
linear-gradient(#101010, #101010) padding-box,
|
||
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||
border-radius: 12px;
|
||
|
||
font-family: comfortaa;
|
||
">
|
||
|
||
<h1
|
||
style="color:white;
|
||
font-family: comfortaa;">{username} успешно поменял данные. УРА! УРА! УРА!!!</h1>
|
||
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td> </td>
|
||
</tr>
|
||
</table>
|
||
</body>
|
||
</html>
|
||
""",
|
||
subtype="html",
|
||
)
|
||
return email
|