Restructure email sending

smtp and mailgun now implement an emailClient interface, which the
Emailer can use.
This commit is contained in:
Harvey Tindall
2020-09-13 21:07:15 +01:00
parent 831296a3e8
commit 51839b5942
5 changed files with 120 additions and 84 deletions

View File

@@ -71,10 +71,12 @@ func pwrMonitor(app *appContext, watcher *fsnotify.Watcher) {
app.err.Printf("Couldn't find email for user \"%s\". Make sure it's set", pwr.Username)
return
}
if app.email.constructReset(pwr, app) != nil {
if err := app.email.constructReset(pwr, app); err != nil {
app.err.Printf("Failed to construct password reset email for %s", pwr.Username)
} else if app.email.send(address, app) != nil {
app.debug.Printf("%s: Error: %s", pwr.Username, err)
} else if err := app.email.send(address); err != nil {
app.err.Printf("Failed to send password reset email to \"%s\"", address)
app.debug.Printf("%s: Error: %s", pwr.Username, err)
} else {
app.info.Printf("Sent password reset email to \"%s\"", address)
}