mailer

package
v0.0.0-...-e3e9b0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailParams

type EmailParams struct {
	Token      string
	Type       string
	RedirectTo string
}

type MailClient

type MailClient interface {
	Mail(string, string, string, string, map[string]interface{}) error
}

type Mailer

type Mailer interface {
	Send(user *models.User, subject, body string, data map[string]interface{}) error
	InviteMail(r *http.Request, user *models.User, otp, referrerURL string, externalURL *url.URL) error
	ConfirmationMail(r *http.Request, user *models.User, otp, referrerURL string, externalURL *url.URL) error
	RecoveryMail(r *http.Request, user *models.User, otp, referrerURL string, externalURL *url.URL) error
	MagicLinkMail(r *http.Request, user *models.User, otp, referrerURL string, externalURL *url.URL) error
	EmailChangeMail(r *http.Request, user *models.User, otpNew, otpCurrent, referrerURL string, externalURL *url.URL) error
	ReauthenticateMail(r *http.Request, user *models.User, otp string) error
	ValidateEmail(email string) error
	GetEmailActionLink(user *models.User, actionType, referrerURL string, externalURL *url.URL) (string, error)
}

Mailer defines the interface a mailer must implement.

func NewMailer

func NewMailer(globalConfig *conf.GlobalConfiguration) Mailer

NewMailer returns a new gotrue mailer

type TemplateMailer

type TemplateMailer struct {
	SiteURL string
	Config  *conf.GlobalConfiguration
	Mailer  MailClient
}

TemplateMailer will send mail and use templates from the site for easy mail styling

func (*TemplateMailer) ConfirmationMail

func (m *TemplateMailer) ConfirmationMail(r *http.Request, user *models.User, otp, referrerURL string, externalURL *url.URL) error

ConfirmationMail sends a signup confirmation mail to a new user

func (*TemplateMailer) EmailChangeMail

func (m *TemplateMailer) EmailChangeMail(r *http.Request, user *models.User, otpNew, otpCurrent, referrerURL string, externalURL *url.URL) error

EmailChangeMail sends an email change confirmation mail to a user

func (m TemplateMailer) GetEmailActionLink(user *models.User, actionType, referrerURL string, externalURL *url.URL) (string, error)

GetEmailActionLink returns a magiclink, recovery or invite link based on the actionType passed.

func (*TemplateMailer) InviteMail

func (m *TemplateMailer) InviteMail(r *http.Request, user *models.User, otp, referrerURL string, externalURL *url.URL) error

InviteMail sends a invite mail to a new user

func (*TemplateMailer) MagicLinkMail

func (m *TemplateMailer) MagicLinkMail(r *http.Request, user *models.User, otp, referrerURL string, externalURL *url.URL) error

MagicLinkMail sends a login link mail

func (*TemplateMailer) ReauthenticateMail

func (m *TemplateMailer) ReauthenticateMail(r *http.Request, user *models.User, otp string) error

ReauthenticateMail sends a reauthentication mail to an authenticated user

func (*TemplateMailer) RecoveryMail

func (m *TemplateMailer) RecoveryMail(r *http.Request, user *models.User, otp, referrerURL string, externalURL *url.URL) error

RecoveryMail sends a password recovery mail

func (TemplateMailer) Send

func (m TemplateMailer) Send(user *models.User, subject, body string, data map[string]interface{}) error

Send can be used to send one-off emails to users

func (TemplateMailer) ValidateEmail

func (m TemplateMailer) ValidateEmail(email string) error

ValidateEmail returns nil if the email is valid, otherwise an error indicating the reason it is invalid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL