Browse Source

修改email基础配置数据

main
pixel 4 years ago
parent
commit
13d48741c0
  1. 2
      server/config.yaml
  2. 12
      server/utils/email.go

2
server/config.yaml

@ -11,7 +11,7 @@ jwt:
# mysql connect configuration # mysql connect configuration
mysql: mysql:
username: root username: root
password: 'root'
password: 'Aa@6447985'
path: '127.0.0.1:3306' path: '127.0.0.1:3306'
db-name: 'qmPlus' db-name: 'qmPlus'
config: 'charset=utf8mb4&parseTime=True&loc=Local' config: 'charset=utf8mb4&parseTime=True&loc=Local'

12
server/utils/email.go

@ -1,10 +1,10 @@
package utils package utils
import ( import (
"crypto/tls"
"fmt" "fmt"
"strings"
"net/smtp" "net/smtp"
"crypto/tls"
"strings"
"gin-vue-admin/global" "gin-vue-admin/global"
@ -31,9 +31,9 @@ func send(to []string, subject string, body string) error {
auth := smtp.PlainAuth("", from, secret, host) auth := smtp.PlainAuth("", from, secret, host)
e := email.NewEmail() e := email.NewEmail()
if nickName == "" {
if nickName != "" {
e.From = fmt.Sprintf("%s <%s>", nickName, from) e.From = fmt.Sprintf("%s <%s>", nickName, from)
}else{
} else {
e.From = from e.From = from
} }
e.To = to e.To = to
@ -43,8 +43,8 @@ func send(to []string, subject string, body string) error {
hostAddr := fmt.Sprintf("%s:%d", host, port) hostAddr := fmt.Sprintf("%s:%d", host, port)
if isSSL { if isSSL {
err = e.SendWithTLS(hostAddr, auth, &tls.Config{ServerName: host}) err = e.SendWithTLS(hostAddr, auth, &tls.Config{ServerName: host})
}else{
} else {
err = e.Send(hostAddr, auth) err = e.Send(hostAddr, auth)
} }
return err return err
}
}
Loading…
Cancel
Save