Add MailerSend and template-based email verification
Introduced support for MailerSend as an email provider alongside SMTP, with configuration options in settings. Added Jinja2-based multi-language email templates for verification emails, and refactored the email sending logic to use these templates and support language selection based on user country code. Updated related services and API endpoints to pass country code and handle new response formats. Added dependencies for Jinja2 and MailerSend.
This commit is contained in:
141
app/templates/email/verification_en.html
Normal file
141
app/templates/email/verification_en.html
Normal file
@@ -0,0 +1,141 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Email Verification - {{ server_name }}</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.header {
|
||||
background: linear-gradient(135deg, #ED8EA6 0%, #FF6B9D 100%);
|
||||
color: white;
|
||||
padding: 40px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.header h1 {
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.header p {
|
||||
margin: 10px 0 0 0;
|
||||
font-size: 16px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.content {
|
||||
padding: 40px 30px;
|
||||
}
|
||||
.greeting {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.message {
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
color: #555;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.code-box {
|
||||
background: #f8f9fa;
|
||||
border: 2px solid #ED8EA6;
|
||||
border-radius: 12px;
|
||||
padding: 25px;
|
||||
text-align: center;
|
||||
margin: 30px 0;
|
||||
}
|
||||
.code {
|
||||
font-size: 36px;
|
||||
font-weight: bold;
|
||||
letter-spacing: 8px;
|
||||
color: #ED8EA6;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
.expiry {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.warning-box {
|
||||
background: #fff3cd;
|
||||
border-left: 4px solid #ffc107;
|
||||
border-radius: 6px;
|
||||
padding: 20px;
|
||||
margin: 30px 0;
|
||||
}
|
||||
.warning-box h3 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 16px;
|
||||
color: #856404;
|
||||
}
|
||||
.warning-box ul {
|
||||
margin: 10px 0;
|
||||
padding-left: 20px;
|
||||
color: #856404;
|
||||
}
|
||||
.warning-box li {
|
||||
margin: 8px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.footer {
|
||||
background: #2c3e50;
|
||||
color: #ecf0f1;
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
}
|
||||
.footer p {
|
||||
margin: 5px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>Email Verification</h1>
|
||||
<p>Verify Your Account</p>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="greeting">Hello, {{ username }}!</div>
|
||||
|
||||
<div class="message">
|
||||
<p>Thank you for registering with {{ server_name }}. To complete your account verification, please use the following verification code:</p>
|
||||
</div>
|
||||
|
||||
<div class="code-box">
|
||||
<div class="code">{{ code }}</div>
|
||||
<div class="expiry">This code will expire in <strong>{{ expiry_minutes }} minutes</strong></div>
|
||||
</div>
|
||||
|
||||
<div class="warning-box">
|
||||
<h3>Security Notice</h3>
|
||||
<ul>
|
||||
<li>Do not share this verification code with anyone</li>
|
||||
<li>If you did not request this code, please ignore this email</li>
|
||||
<li>For your account security, do not use the same password on other websites</li>
|
||||
<li>This code can only be used once</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>© {{ year }} {{ server_name }}. All rights reserved.</p>
|
||||
<p>This email was sent automatically, please do not reply.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
18
app/templates/email/verification_en.txt
Normal file
18
app/templates/email/verification_en.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
Hello, {{ username }}!
|
||||
|
||||
Thank you for registering with {{ server_name }}. To complete your account verification, please use the following verification code:
|
||||
|
||||
Verification Code: {{ code }}
|
||||
|
||||
This code will expire in {{ expiry_minutes }} minutes.
|
||||
|
||||
Security Notice:
|
||||
- Do not share this verification code with anyone
|
||||
- If you did not request this code, please ignore this email
|
||||
- For your account security, do not use the same password on other websites
|
||||
- This code can only be used once
|
||||
|
||||
---
|
||||
© {{ year }} {{ server_name }}. All rights reserved.
|
||||
This email was sent automatically, please do not reply.
|
||||
|
||||
141
app/templates/email/verification_zh.html
Normal file
141
app/templates/email/verification_zh.html
Normal file
@@ -0,0 +1,141 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>邮箱验证 - {{ server_name }}</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.header {
|
||||
background: linear-gradient(135deg, #ED8EA6 0%, #FF6B9D 100%);
|
||||
color: white;
|
||||
padding: 40px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.header h1 {
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.header p {
|
||||
margin: 10px 0 0 0;
|
||||
font-size: 16px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.content {
|
||||
padding: 40px 30px;
|
||||
}
|
||||
.greeting {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.message {
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
color: #555;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.code-box {
|
||||
background: #f8f9fa;
|
||||
border: 2px solid #ED8EA6;
|
||||
border-radius: 12px;
|
||||
padding: 25px;
|
||||
text-align: center;
|
||||
margin: 30px 0;
|
||||
}
|
||||
.code {
|
||||
font-size: 36px;
|
||||
font-weight: bold;
|
||||
letter-spacing: 8px;
|
||||
color: #ED8EA6;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
.expiry {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.warning-box {
|
||||
background: #fff3cd;
|
||||
border-left: 4px solid #ffc107;
|
||||
border-radius: 6px;
|
||||
padding: 20px;
|
||||
margin: 30px 0;
|
||||
}
|
||||
.warning-box h3 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 16px;
|
||||
color: #856404;
|
||||
}
|
||||
.warning-box ul {
|
||||
margin: 10px 0;
|
||||
padding-left: 20px;
|
||||
color: #856404;
|
||||
}
|
||||
.warning-box li {
|
||||
margin: 8px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.footer {
|
||||
background: #2c3e50;
|
||||
color: #ecf0f1;
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
}
|
||||
.footer p {
|
||||
margin: 5px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>邮箱验证</h1>
|
||||
<p>Email Verification</p>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="greeting">你好,{{ username }}!</div>
|
||||
|
||||
<div class="message">
|
||||
<p>感谢你注册 {{ server_name }}。为了完成账户验证,请使用以下验证码:</p>
|
||||
</div>
|
||||
|
||||
<div class="code-box">
|
||||
<div class="code">{{ code }}</div>
|
||||
<div class="expiry">⏱️ 验证码将在 <strong>{{ expiry_minutes }} 分钟</strong>内有效</div>
|
||||
</div>
|
||||
|
||||
<div class="warning-box">
|
||||
<h3>安全提示</h3>
|
||||
<ul>
|
||||
<li>请不要与任何人分享此验证码</li>
|
||||
<li>如果您没有请求此验证码,请忽略这封邮件</li>
|
||||
<li>为了账户安全,请勿在其他网站使用相同的密码</li>
|
||||
<li>验证码仅能使用一次</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>© {{ year }} {{ server_name }}. 保留所有权利。</p>
|
||||
<p>此邮件由系统自动发送,请勿回复。</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
18
app/templates/email/verification_zh.txt
Normal file
18
app/templates/email/verification_zh.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
你好,{{ username }}!
|
||||
|
||||
感谢你注册 {{ server_name }}。为了完成账户验证,请使用以下验证码:
|
||||
|
||||
验证码:{{ code }}
|
||||
|
||||
验证码将在 {{ expiry_minutes }} 分钟内有效。
|
||||
|
||||
安全提示:
|
||||
- 请不要与任何人分享此验证码
|
||||
- 如果您没有请求此验证码,请忽略这封邮件
|
||||
- 为了账户安全,请勿在其他网站使用相同的密码
|
||||
- 验证码仅能使用一次
|
||||
|
||||
---
|
||||
© {{ year }} {{ server_name }}. 保留所有权利。
|
||||
此邮件由系统自动发送,请勿回复。
|
||||
|
||||
Reference in New Issue
Block a user