Переделал письмо
This commit is contained in:
parent
1f5fc664c3
commit
af6988c940
2 changed files with 16 additions and 3 deletions
|
@ -5,17 +5,24 @@ from pydantic import EmailStr
|
|||
from app.config import settings
|
||||
|
||||
|
||||
def create_registration_confirmation_template(username: str, email_to: EmailStr, confirmation_link: str):
|
||||
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
|
||||
color = "color:red"
|
||||
|
||||
email.set_content(
|
||||
f"""
|
||||
<h1>{username}, лови аптечку</h1>
|
||||
{confirmation_link}
|
||||
{confirmation_code}
|
||||
<style>
|
||||
h1{color}
|
||||
</style>
|
||||
""",
|
||||
subtype="html",
|
||||
)
|
||||
|
@ -28,11 +35,14 @@ def create_data_change_confirmation_email(username: str, email_to: EmailStr, con
|
|||
email["Subject"] = "Подтверждение изменения данных"
|
||||
email["From"] = settings.SMTP_USER
|
||||
email["To"] = email_to
|
||||
|
||||
color = "color:red"
|
||||
email.set_content(
|
||||
f"""
|
||||
<h1>{username}, лови аптечку</h1>
|
||||
{confirmation_code}
|
||||
<style>
|
||||
h1{color}
|
||||
</style>
|
||||
""",
|
||||
subtype="html",
|
||||
)
|
||||
|
|
|
@ -30,7 +30,10 @@ def send_registration_confirmation_email(user_data: dict) -> None:
|
|||
confirmation_link = settings.INVITATION_LINK_HOST + "/api/users/email_verification/" + invitation_token
|
||||
|
||||
msg_content = create_registration_confirmation_template(
|
||||
username=user_data.username, email_to=user_data.email_to, confirmation_link=confirmation_link
|
||||
username=user_data.username,
|
||||
email_to=user_data.email_to,
|
||||
confirmation_link=confirmation_link,
|
||||
confirmation_code=user_data.confirmation_code
|
||||
)
|
||||
|
||||
with smtplib.SMTP_SSL(settings.SMTP_HOST, settings.SMTP_PORT) as server:
|
||||
|
|
Loading…
Add table
Reference in a new issue