mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-19 01:58:00 +08:00
1、实现通过SSL、TSL发送邮件
2、增加用户真实姓名字段 3、优化项目列表显示 4、实现限定文档历史记录数量 5、优化部分页面的用户体验
This commit is contained in:
39
mail/smtp.go
39
mail/smtp.go
@@ -85,8 +85,8 @@ func (s *SMTPConfig) Auth() smtp.Auth {
|
||||
case "SSL":
|
||||
fallthrough
|
||||
default:
|
||||
//auth = smtp.PlainAuth(s.Identity, s.Username, s.Password, s.Host)
|
||||
auth = unencryptedAuth{smtp.PlainAuth(s.Identity, s.Username, s.Password, s.Host)}
|
||||
auth = smtp.PlainAuth(s.Identity, s.Username, s.Password, s.Host)
|
||||
//auth = unencryptedAuth{smtp.PlainAuth(s.Identity, s.Username, s.Password, s.Host)}
|
||||
}
|
||||
return auth
|
||||
}
|
||||
@@ -214,35 +214,42 @@ func (c *SMTPClient) SendTLS(m Mail, message bytes.Buffer) error {
|
||||
var ct *smtp.Client
|
||||
var err error
|
||||
// TLS config
|
||||
//tlsconfig := &tls.Config{
|
||||
// InsecureSkipVerify: true,
|
||||
// ServerName: c.host,
|
||||
//}
|
||||
tlsconfig := &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
ServerName: c.host,
|
||||
}
|
||||
|
||||
// Here is the key, you need to call tls.Dial instead of smtp.Dial
|
||||
// for smtp servers running on 465 that require an ssl connection
|
||||
// from the very beginning (no starttls)
|
||||
conn, err := tls.Dial("tcp", c.host+":"+c.port, nil)
|
||||
conn, err := tls.Dial("tcp", c.host+":"+c.port, tlsconfig)
|
||||
if err != nil {
|
||||
log.Println(err, c.host)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
ct, err = smtp.NewClient(conn, c.host)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
fmt.Println(c.smtpAuth)
|
||||
// Auth
|
||||
if err = ct.Auth(c.smtpAuth); err != nil {
|
||||
log.Println("Auth Error:",
|
||||
err,
|
||||
c.user,
|
||||
)
|
||||
return err
|
||||
}
|
||||
//if err := ct.StartTLS(tlsconfig);err != nil {
|
||||
// fmt.Println(err)
|
||||
// return err
|
||||
//}
|
||||
|
||||
fmt.Println(c.smtpAuth)
|
||||
if ok,_ := ct.Extension("AUTH"); ok {
|
||||
// Auth
|
||||
if err = ct.Auth(c.smtpAuth); err != nil {
|
||||
log.Println("Auth Error:",
|
||||
err,
|
||||
c.user,
|
||||
)
|
||||
return err
|
||||
}
|
||||
}
|
||||
// To && From
|
||||
if err = ct.Mail(m.From); err != nil {
|
||||
log.Println("Mail Error:", err, m.From)
|
||||
|
Reference in New Issue
Block a user