diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-08-30 22:53:59 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-08-30 22:53:59 +0200 |
commit | d4fe97a9a5437d71a5a29f413ba7be6efe5f7da3 (patch) | |
tree | 1df00e016300304318997e8f04053bf523b8d85e /mails.go | |
parent | 11ec26feeabced25281b8637f928a8096690c54b (diff) | |
download | mailremind-d4fe97a9a5437d71a5a29f413ba7be6efe5f7da3.tar.gz mailremind-d4fe97a9a5437d71a5a29f413ba7be6efe5f7da3.tar.bz2 mailremind-d4fe97a9a5437d71a5a29f413ba7be6efe5f7da3.zip |
Password reset implemented
Diffstat (limited to 'mails.go')
-rw-r--r-- | mails.go | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -18,7 +18,10 @@ func loadMailTpl(tplroot, name string) *template.Template { return tpl } -var mailActivationcode *template.Template +var ( + mailActivationcode *template.Template + mailPwreset *template.Template +) func initMails() { tplroot, err := conf.GetString("paths", "mailtpls") @@ -27,6 +30,7 @@ func initMails() { } mailActivationcode = loadMailTpl(tplroot, "activationcode") + mailPwreset = loadMailTpl(tplroot, "pwreset") } type activationcodeData struct { @@ -50,3 +54,21 @@ func SendActivationcode(to, acCode string, uid model.DBID) bool { return Mail(to, MailFrom, buf.Bytes()) } + +func SendPwresetLink(to, code string, uid model.DBID) bool { + buf := new(bytes.Buffer) + fmt.Fprintf(buf, "To: %s\n", to) + fmt.Fprintf(buf, "From: %s\n", MailFrom) + fmt.Fprintf(buf, "Subject: Password reset request for your mailremind account\n") + fmt.Fprintf(buf, "Date: %s\n", time.Now().Format(time.RFC822)) + + fmt.Fprintln(buf, "") + + url := fmt.Sprintf("%s/pwreset?U=%s&Code=%s", baseurl, uid, code) + if err := mailPwreset.Execute(buf, activationcodeData{url}); err != nil { + log.Printf("Error while executing mail template (pwreset): %s", err) + return false + } + + return Mail(to, MailFrom, buf.Bytes()) +} |