Refactoring
This commit is contained in:
parent
e48f093d6b
commit
9b04e88b72
2 changed files with 10 additions and 2 deletions
|
@ -115,8 +115,9 @@ func add(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Send the email
|
||||
err = sendMail(SendMailTplData{
|
||||
sendMailTplData := SendMailTplData{
|
||||
From: "alice@resdigita.org",
|
||||
To: user.OtherMailbox,
|
||||
RelTemplatePath: "user/mail.txt",
|
||||
|
@ -125,7 +126,13 @@ func add(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
|
|||
"SebAddress": "https://www.gvoisins.org",
|
||||
"Code": "...",
|
||||
},
|
||||
})
|
||||
}
|
||||
err = sendMail(sendMailTplData)
|
||||
if err != nil {
|
||||
log.Printf("add(user) sendMail: %v", err)
|
||||
log.Printf("add(user) sendMail: %v", user)
|
||||
log.Printf("add(user) sendMail: %v", sendMailTplData)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
1
utils.go
1
utils.go
|
@ -54,6 +54,7 @@ func suggestPassword() string {
|
|||
|
||||
// Sends an email according to the enclosed information
|
||||
func sendMail(sendMailTplData SendMailTplData) error {
|
||||
log.Printf("sendMail")
|
||||
templateMail := template.Must(template.ParseFiles(templatePath + "/" + sendMailTplData.RelTemplatePath))
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
err := templateMail.Execute(buf, sendMailTplData)
|
||||
|
|
Loading…
Reference in a new issue