feat: add Docker deployment and Microsoft OAuth support

This commit is contained in:
2026-04-18 14:02:24 +08:00
parent 6704cfb418
commit e69c0dd226
53 changed files with 5139 additions and 4029 deletions

View File

@@ -1,23 +1,29 @@
package services
import (
"gopkg.in/gomail.v2"
"mengpost-backend/models"
)
// SendMail 通过指定账户发送邮件. body 支持纯文本或 HTML.
func SendMail(acc *models.Account, to, subject, body string, html bool) error {
m := gomail.NewMessage()
m.SetHeader("From", acc.Email)
m.SetHeader("To", to)
m.SetHeader("Subject", subject)
if html {
m.SetBody("text/html", body)
} else {
m.SetBody("text/plain", body)
}
d := gomail.NewDialer(acc.SMTPHost, acc.SMTPPort, acc.Email, acc.Password)
d.SSL = acc.UseTLS && acc.SMTPPort == 465
return d.DialAndSend(m)
}
package services
import (
"gopkg.in/gomail.v2"
"mengpost-backend/models"
)
// SendMail 通过指定账户发送邮件. body 支持纯文本或 HTML.
func SendMail(acc *models.Account, to, subject, body string, html bool) error {
if acc.AuthType == models.AuthTypeOAuthMicrosoft {
return sendMailMicrosoftOAuth(acc, to, subject, body, html)
}
m := gomail.NewMessage()
m.SetHeader("From", acc.Email)
m.SetHeader("To", to)
m.SetHeader("Subject", subject)
if html {
m.SetBody("text/html", body)
} else {
m.SetBody("text/plain", body)
}
d := gomail.NewDialer(acc.SMTPHost, acc.SMTPPort, acc.Email, acc.Password)
d.SSL = acc.UseTLS && acc.SMTPPort == 465
if tc := SMTPTLSConfig(acc); tc != nil {
d.TLSConfig = tc
}
return d.DialAndSend(m)
}