Refactoring
This commit is contained in:
parent
7f1073e258
commit
e48f093d6b
1 changed files with 10 additions and 0 deletions
10
utils.go
10
utils.go
|
@ -5,6 +5,7 @@ import (
|
|||
"crypto/tls"
|
||||
"log"
|
||||
"net"
|
||||
"net/smtp"
|
||||
|
||||
"math/rand"
|
||||
|
||||
|
@ -56,5 +57,14 @@ func sendMail(sendMailTplData SendMailTplData) error {
|
|||
templateMail := template.Must(template.ParseFiles(templatePath + "/" + sendMailTplData.RelTemplatePath))
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
err := templateMail.Execute(buf, sendMailTplData)
|
||||
message := buf.Bytes()
|
||||
auth := smtp.PlainAuth("", config.SMTPUsername, config.SMTPPassword, config.SMTPServer)
|
||||
log.Printf("auth: %v", auth)
|
||||
err = smtp.SendMail(config.SMTPServer+":587", auth, config.SMTPUsername, []string{user.OtherMailbox}, message)
|
||||
if err != nil {
|
||||
log.Printf("email send error %v", err)
|
||||
return err
|
||||
}
|
||||
log.Printf("Mail sent.")
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue