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