add: edit send email text

This commit is contained in:
behruz-dev
2025-08-28 12:11:43 +05:00
parent 3211ed7567
commit 2263de00a1
2 changed files with 78 additions and 10 deletions

View File

@@ -5,11 +5,79 @@ from django.conf import settings
@shared_task
def send_confirmation_code_to_email(email, code):
send_mail(
"Avto Cargo uchun tasdiqlash kod.",
f"Bu sizning tasdiqlash kodingiz: {code}",
settings.EMAIL_HOST_USER,
[email],
fail_silently=False,
)
def send_confirmation_email(user_email, code):
from django.core.mail import EmailMultiAlternatives
subject = "Код подтверждения для WISDOM Cargo"
from_email = settings.EMAIL_HOST_USER
to = [user_email]
html_content = f"""
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f4f6f8;
margin: 0;
padding: 0;
}}
.container {{
max-width: 600px;
background: #ffffff;
margin: 30px auto;
padding: 30px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}}
h2 {{
color: #333333;
}}
.code-box {{
margin: 20px 0;
padding: 15px;
background: #f0f9ff;
border: 1px dashed #007bff;
text-align: center;
font-size: 24px;
font-weight: bold;
letter-spacing: 3px;
color: #007bff;
border-radius: 8px;
}}
p {{
color: #555555;
font-size: 15px;
line-height: 1.6;
}}
.footer {{
margin-top: 30px;
font-size: 13px;
color: #999999;
text-align: center;
}}
</style>
</head>
<body>
<div class="container">
<h2>Код подтверждения для WISDOM Cargo</h2>
<p>Уважаемый <strong>{user_email}</strong>,</p>
<p>Для завершения процесса регистрации на платформе <b>Avto Cargo</b>, пожалуйста, используйте следующий код подтверждения:</p>
<div class="code-box">{code}</div>
<p>Пожалуйста, используйте этот код в течение <b>5 минут</b> для завершения регистрации.</p>
<p>Если код не работает или вам нужна дополнительная помощь, свяжитесь с нами по адресу
<a href="mailto:wisdomcargo1@gmail.com">wisdomcargo1@gmail.com</a>.</p>
<div class="footer">
С уважением,<br>
Команда Wisdom Cargo
</div>
</div>
</body>
</html>
"""
msg = EmailMultiAlternatives(subject, "", from_email, to)
msg.attach_alternative(html_content, "text/html")
msg.send()

View File

@@ -8,7 +8,7 @@ from rest_framework_simplejwt.tokens import RefreshToken
from core.apps.accounts import serializers
from core.apps.accounts import models
from core.apps.accounts.cache import cache_user_credentials, cache_user_confirmation_code
from core.apps.accounts.tasks import send_confirmation_code_to_email
from core.apps.accounts.tasks import send_confirmation_email
class RegisterApiView(generics.GenericAPIView):
@@ -28,7 +28,7 @@ class RegisterApiView(generics.GenericAPIView):
cache_user_confirmation_code(
email=email, code=code, time=60*5
)
send_confirmation_code_to_email.delay(email, code)
send_confirmation_email.delay(email, code)
return Response(
{'success': True, 'message': "code sent"},
status=200