Browse Source

otp template updated for dovoodi

master
Mohsen Taba 1 day ago
parent
commit
799d401e27
  1. 137
      utils/__init__.py

137
utils/__init__.py

@ -95,8 +95,8 @@ def send_email(recipient, code):
import requests import requests
from django.conf import settings from django.conf import settings
if not settings.RESEND_API_KEY:
print("RESEND_API_KEY is not set in settings.")
if not getattr(settings, "RESEND_API_KEY", None):
logger.warning("RESEND_API_KEY is not set in settings.")
return False return False
url = "https://api.resend.com/emails" url = "https://api.resend.com/emails"
@ -105,48 +105,97 @@ def send_email(recipient, code):
"Content-Type": "application/json", "Content-Type": "application/json",
} }
subject = 'Verification Code'
site_domain = getattr(settings, "SITE_DOMAIN", "https://dovodi.newhorizonco.uk/")
subject = "Код подтверждения | Verification Code"
html_content = f""" html_content = f"""
<div
style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; max-width: 600px; margin: 0 auto; background-color: #FAF6E9; padding: 20px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid #25D076; overflow: hidden;">
<!-- Logo / Header Section with Vertical Gradient -->
<!-- The negative margin makes it stretch flush to the edges of the padded container -->
<div
style="text-align: center; padding: 40px 20px 40px 20px; margin: -20px -20px 25px -20px; background: linear-gradient(to bottom, #052B18 30%, #0A522E 80%);">
<!-- UPDATE THE SRC BELOW WITH YOUR ACTUAL LOGO URL -->
<img src="{settings.SITE_DOMAIN}/static/images/logo1.svg" alt="Imam Javad Online School Logo" style="width: 150px; height: auto;">
</div>
<!-- Main Heading -->
<h2 style="color: #0A522E; text-align: center; font-weight: 800; margin-top: 0;">Verification Code</h2>
<!-- Greeting and Intro -->
<p style="font-size: 17px; color: #333333; line-height: 1.6; margin-bottom: 15px;">Hello,</p>
<p style="font-size: 17px; color: #333333; line-height: 1.6;">Your verification code for <strong
style="color: #0A522E;">Imam Javad Online School</strong> is:</p>
<!-- Stylized Verification Code Box -->
<div style="text-align: center; margin: 40px 0;">
<span
style="font-size: 40px; font-weight: 900; color: #0A522E; letter-spacing: 6px; background-color: rgba(37, 208, 118, 0.2); padding: 15px 30px; border-radius: 8px; border: 2px dashed #0A522E; display: inline-block;">{code}</span>
</div>
<!-- Disclaimer -->
<p style="font-size: 14px; color: #777777; text-align: center; margin-top: 10px;">This code will expire shortly. If
you did not request this code, please ignore this email.</p>
<!-- Footer Section -->
<hr style="border: 0; border-top: 1px solid #d4d0c3; margin: 30px 0;">
<p style="font-size: 13px; color: #999999; text-align: center; line-height: 1.5; margin-bottom: 0;">
<strong style="color: #0A522E;">Imam Javad Online School</strong><br>
имам джавад | امام جواد<br>
Learn more: <a href="https://imamjavad.nwhco.ir/"
style="color: #0A522E; text-decoration: none;">imamjavad.nwhco.ir</a><br>
<span style="font-style: italic;">Contact us: <a href="mailto:[email protected]"
style="color: #0A522E; text-decoration: none;">support@yourwebsite.com</a></span>
</p>
</div>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Код подтверждения | Verification Code</title>
</head>
<body style="margin: 0; padding: 0; background-color: #F4F6F9; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: #15171C; -webkit-font-smoothing: antialiased;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed; background-color: #F4F6F9; padding: 40px 16px;">
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 540px; background-color: #FFFFFF; border-radius: 16px; border: 1px solid #E2E8F0; box-shadow: 0 4px 20px -2px rgba(21, 23, 28, 0.06); overflow: hidden;">
<!-- Top Gradient Accent Line -->
<tr>
<td style="height: 4px; background: linear-gradient(90deg, #5172E1 0%, #1C458C 100%); line-height: 4px; font-size: 4px;">&nbsp;</td>
</tr>
<!-- Header with Logo -->
<tr>
<td style="padding: 32px 32px 20px 32px; text-align: center; background-color: #FAFAFC; border-bottom: 1px solid #F1F3F7;">
<img src="{site_domain}/static/images/dovoodi_logo.svg" alt="Dovodi Logo" style="height: 38px; width: auto; max-width: 160px; display: inline-block;" />
</td>
</tr>
<!-- Main Body Section -->
<tr>
<td style="padding: 36px 36px 28px 36px;">
<!-- Security Badge -->
<div style="text-align: center; margin-bottom: 16px;">
<span style="display: inline-block; background-color: #EEF2FF; color: #3B66DE; border: 1px solid #D5DEFF; padding: 4px 12px; border-radius: 9999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">
Безопасность / Security
</span>
</div>
<!-- Main Title -->
<h1 style="margin: 0 0 12px 0; font-size: 22px; font-weight: 800; color: #15171C; text-align: center; line-height: 1.3;">
Код подтверждения
</h1>
<!-- Intro Message -->
<p style="margin: 0 0 24px 0; font-size: 14px; color: #646A75; text-align: center; line-height: 1.6;">
Используйте следующий одноразовый код для входа или подтверждения учетной записи в <strong>Dovodi</strong>:
</p>
<!-- OTP Box -->
<div style="text-align: center; margin: 28px 0; padding: 22px; background-color: #F8FAFD; border: 1.5px dashed #5172E1; border-radius: 14px;">
<span style="font-family: 'SF Pro Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; font-size: 38px; font-weight: 800; color: #15171C; letter-spacing: 10px; display: inline-block;">
{code}
</span>
</div>
<!-- Expiry & Security Notice -->
<div style="background-color: #FFFBEB; border: 1px solid #FDE68A; border-radius: 10px; padding: 12px 16px; margin-bottom: 24px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="font-size: 12px; color: #92400E; line-height: 1.5;">
<strong>Внимание:</strong> Срок действия кода истекает через 5 минут. Если вы не запрашивали этот код, просто проигнорируйте это письмо.
</td>
</tr>
</table>
</div>
<p style="margin: 0; font-size: 13px; color: #8C93A0; text-align: center; line-height: 1.5;">
Никому не передавайте этот код в целях безопасности вашего аккаунта.
</p>
</td>
</tr>
<!-- Footer Section -->
<tr>
<td style="padding: 24px 36px; background-color: #F8F9FB; border-top: 1px solid #EEF0F4; text-align: center;">
<p style="margin: 0 0 6px 0; font-size: 13px; font-weight: 700; color: #15171C;">
Dovodi
</p>
<p style="margin: 0 0 12px 0; font-size: 12px; color: #646A75;">
<a href="https://dovodi.newhorizonco.uk/" style="color: #5172E1; text-decoration: none; font-weight: 600;">dovodi.newhorizonco.uk</a>
&nbsp;&nbsp;
<a href="mailto:[EMAIL_ADDRESS]" style="color: #5172E1; text-decoration: none; font-weight: 600;">[EMAIL_ADDRESS]</a>
</p>
<p style="margin: 0; font-size: 11px; color: #9AA0AC; line-height: 1.4;">
© 2026 Dovodi. Все права защищены.
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
""" """
payload = { payload = {
@ -161,7 +210,7 @@ def send_email(recipient, code):
response.raise_for_status() response.raise_for_status()
return True return True
except Exception as e: except Exception as e:
print(f"Failed to send email via Resend: {str(e)}")
logger.error(f"Failed to send email via Resend: {str(e)}")
return False return False

Loading…
Cancel
Save