package mail import ( "context" "fmt" "html" ) // Mailer sends emails. type Mailer interface { Send(ctx context.Context, email, subject, text, htmlBody string) error } func SendEmailVerificationEmail(ctx context.Context, baseURL string, mailer Mailer, token, email string) error { verifyURL := baseURL + "/verify?token=" + token text := "Click here to verify your email: " + verifyURL htmlBody := fmt.Sprintf( `
Click here to verify your email.
`, html.EscapeString(verifyURL), ) return mailer.Send(ctx, email, "Verify your email", text, htmlBody) } func SendPasswordResetEmail(ctx context.Context, baseURL string, mailer Mailer, token, email string) error { resetURL := baseURL + "/reset-password?token=" + token text := "Click here to reset your password: " + resetURL htmlBody := fmt.Sprintf( `Click here to reset your password.
`, html.EscapeString(resetURL), ) return mailer.Send(ctx, email, "Reset your password", text, htmlBody) } func SendTenantInvitationEmail(ctx context.Context, baseURL string, mailer Mailer, token, email string) error { acceptURL := baseURL + "/accept-invitation?token=" + token text := "You've been invited to join a team. Click here to accept: " + acceptURL htmlBody := fmt.Sprintf( `You've been invited to join a team. Click here to accept.
`, html.EscapeString(acceptURL), ) return mailer.Send(ctx, email, "You've been invited", text, htmlBody) }