mirror of
https://github.com/acaloiaro/newsbox
synced 2026-07-21 10:12:26 +00:00
29 lines
980 B
Go
29 lines
980 B
Go
package mailers
|
|
|
|
import (
|
|
"fmt"
|
|
"newsbox/internal"
|
|
|
|
"github.com/gobuffalo/buffalo/mail"
|
|
"github.com/gobuffalo/buffalo/render"
|
|
)
|
|
|
|
// SendEmailAddressChangedEmail sends an email to recipient containing a special URL that only that can know, for the purpose of
|
|
// email address verification
|
|
func SendEmailAddressChangedEmail(recipient, verificationURL string) error {
|
|
m := mail.NewMessage()
|
|
|
|
// fill in with your stuff:
|
|
m.Subject = fmt.Sprintf("%s password changed: Verify your email address", internal.SiteName())
|
|
m.From = fmt.Sprintf("noreply@%s", internal.SiteDomain())
|
|
m.To = []string{recipient}
|
|
err := m.AddBody(r.HTML("mail/email_changed.plush.html"), render.Data{"verification_url": verificationURL, "site_name": internal.SiteName()})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = m.AddBody(r.Plain("mail/email_changed.plush.tpl"), render.Data{"verification_url": verificationURL, "site_name": internal.SiteName()})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return smtp.Send(m)
|
|
}
|