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:
咕谷酱
2025-10-12 00:36:47 +08:00
parent a32976857f
commit 6731373ded
15 changed files with 886 additions and 163 deletions

View File

@@ -1,5 +1,5 @@
from enum import Enum
from typing import Annotated, Any
from typing import Annotated, Any, Literal
from pydantic import (
AliasChoices,
@@ -336,6 +336,11 @@ STORAGE_SETTINGS='{
Field(default=30, description="设备信任持续天数"),
"验证服务设置",
]
email_provider: Annotated[
Literal["smtp", "mailersend"],
Field(default="smtp", description="邮件发送提供商smtpSMTP或 mailersendMailerSend"),
"验证服务设置",
]
smtp_server: Annotated[
str,
Field(default="localhost", description="SMTP 服务器地址"),
@@ -366,6 +371,16 @@ STORAGE_SETTINGS='{
Field(default="osu! server", description="发件人名称"),
"验证服务设置",
]
mailersend_api_key: Annotated[
str,
Field(default="", description="MailerSend API Key"),
"验证服务设置",
]
mailersend_from_email: Annotated[
str,
Field(default="", description="MailerSend 发件人邮箱(需要在 MailerSend 中验证)"),
"验证服务设置",
]
# 监控配置
sentry_dsn: Annotated[