newsbox/mailers/welcome_email.go
Adriano Caloiaro 8ae801ae5f
Initial commit
2023-02-15 08:57:48 -08:00

25 lines
715 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)
}