feat(admin): 扩展后台管理与登录安全能力。

- 新增用户、域名、邮箱、别名、邮件、系统设置与模板的管理接口和页面。
- 支持双因素认证、Turnstile、人机验证与管理员 SMTP 测试。
- 增加无人收件/未注册邮件归档、Maildir 同步和数据库迁移支持。
- 更新前端导航、个人中心 2FA 配置以及相关部署示例。
This commit is contained in:
LanQin
2026-06-15 00:37:43 +08:00
parent 3ef8caa319
commit 8a042ae3dc
27 changed files with 3558 additions and 384 deletions
+10 -6
View File
@@ -122,20 +122,24 @@ func writeBase64(w io.Writer, data []byte) {
}
func (a *App) sendSMTP(from string, recipients []string, mimeBytes []byte) error {
addr := net.JoinHostPort(a.cfg.SMTPHost, a.cfg.SMTPPort)
return sendSMTPWithConfig(a.cfg, from, recipients, mimeBytes)
}
func sendSMTPWithConfig(cfg Config, from string, recipients []string, mimeBytes []byte) error {
addr := net.JoinHostPort(cfg.SMTPHost, cfg.SMTPPort)
var auth smtp.Auth
if a.cfg.SMTPUsername != "" {
auth = smtp.PlainAuth("", a.cfg.SMTPUsername, a.cfg.SMTPPassword, a.cfg.SMTPHost)
if cfg.SMTPUsername != "" {
auth = smtp.PlainAuth("", cfg.SMTPUsername, cfg.SMTPPassword, cfg.SMTPHost)
}
if !a.cfg.SMTPRequireTLS {
if !cfg.SMTPRequireTLS {
return smtp.SendMail(addr, auth, from, recipients, mimeBytes)
}
conn, err := tls.Dial("tcp", addr, &tls.Config{ServerName: a.cfg.SMTPHost, MinVersion: tls.VersionTLS12})
conn, err := tls.Dial("tcp", addr, &tls.Config{ServerName: cfg.SMTPHost, MinVersion: tls.VersionTLS12})
if err != nil {
return err
}
defer conn.Close()
client, err := smtp.NewClient(conn, a.cfg.SMTPHost)
client, err := smtp.NewClient(conn, cfg.SMTPHost)
if err != nil {
return err
}