2025-03-16 23:01:50 +08:00
|
|
|
|
namespace LMS.Common.Templates
|
|
|
|
|
|
{
|
|
|
|
|
|
public class EmailTemplateService()
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 注册邮件模板
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public const string RegisterHtmlTemplates = """
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
<html>
|
|
|
|
|
|
<body>
|
2025-03-22 20:48:40 +08:00
|
|
|
|
<h1>LMS注册验证码</h1>
|
|
|
|
|
|
<p>您好,</p>
|
|
|
|
|
|
<p>您的验证码是 <strong>{RegisterCode}</strong></p>
|
|
|
|
|
|
<p>该验证码有效期为 10 分钟,如果不是您本人操作,请忽略此邮件。</p>
|
2025-03-16 23:01:50 +08:00
|
|
|
|
</body>
|
|
|
|
|
|
</html>
|
|
|
|
|
|
""";
|
|
|
|
|
|
|
2025-03-22 20:48:40 +08:00
|
|
|
|
public const string ResetPasswordHtmlTemplates = """
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
<html>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
<h1>LMS重置密码验证码</h1>
|
|
|
|
|
|
<p>您好,</p>
|
|
|
|
|
|
<p>您的验证码是 <strong>{ResetPasswordCode}</strong></p>
|
|
|
|
|
|
<p>该验证码有效期为 10 分钟,如果不是您本人操作,请忽略此邮件。</p>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>
|
|
|
|
|
|
""";
|
|
|
|
|
|
|
|
|
|
|
|
public const string ResetpasswordSuccessMail = """
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
<html>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
<h1>LMS重置密码成功</h1>
|
|
|
|
|
|
<p>您好,</p>
|
|
|
|
|
|
<p>您的重置密码操作已经成功!</p>
|
|
|
|
|
|
<p>您的新密码是 <strong>{NewPassword}</strong></p>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>
|
|
|
|
|
|
""";
|
2025-03-16 23:01:50 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 替换模板的占位符
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="template"></param>
|
|
|
|
|
|
/// <param name="parameters"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string ReplaceTemplate(string template, Dictionary<string, string> parameters)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 替换占位符
|
|
|
|
|
|
foreach (var param in parameters)
|
|
|
|
|
|
{
|
|
|
|
|
|
template = template.Replace($"{{{param.Key}}}", param.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
return template;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|