mailer

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const TemplateExpiration = 10 * time.Second

TemplateExpiration is the time period that the template will be cached for

View Source
const TemplateRetries = 3

TemplateRetries is the amount of time MailMe will try to fetch a URL before giving up

Variables

This section is empty.

Functions

func SafeHTTPClient

func SafeHTTPClient(client *http.Client, log logrus.FieldLogger) *http.Client

SafeHTTPClient returns an http.Client

func SafeRoundtripper

func SafeRoundtripper(trans http.RoundTripper, log logrus.FieldLogger) http.RoundTripper

SafeRoundtripper returns an HTTP Roundtripper with a logger

Types

type MailTemplate

type MailTemplate struct {
	// contains filtered or unexported fields
}

MailTemplate is a mail template

type Mailer

type Mailer interface {
	Send(user *models.User, subject, body string, data map[string]interface{}) error
	InviteMail(user *models.User, referrerURL string) error
	ConfirmationMail(user *models.User, referrerURL string) error
	RecoveryMail(user *models.User, referrerURL string) error
	EmailChangeMail(user *models.User, referrerURL string) error
	ValidateEmail(email string) error
}

Mailer defines the interface a mailer must implement.

func NewMailer

func NewMailer(instanceConfig *conf.Configuration) Mailer

NewMailer returns a new gotrue mailer

type MailmeMailer

type MailmeMailer struct {
	From    string
	Host    string
	Port    int
	User    string
	Pass    string
	BaseURL string
	FuncMap template.FuncMap
	// contains filtered or unexported fields
}

MailmeMailer lets MailMe send templated mails

func (*MailmeMailer) Mail

func (m *MailmeMailer) Mail(to, subjectTemplate, templateURL, defaultTemplate string, templateData map[string]interface{}) error

Mail sends a templated mail. It will try to load the template from a URL, and otherwise fall back to the default

func (*MailmeMailer) MailBody

func (m *MailmeMailer) MailBody(url string, defaultTemplate string, data map[string]interface{}) (string, error)

MailBody contructs the body of the email

type TemplateCache

type TemplateCache struct {
	// contains filtered or unexported fields
}

TemplateCache caches the requested templates

func (*TemplateCache) Get

func (t *TemplateCache) Get(url string) (*template.Template, error)

Get gets a template from remote

func (*TemplateCache) Set

func (t *TemplateCache) Set(key, value string, expirationTime time.Duration) (*template.Template, error)

Set sets a template

type TemplateMailer

type TemplateMailer struct {
	SiteURL string
	Config  *conf.Configuration
	Mailer  *MailmeMailer
}

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

func (*TemplateMailer) ConfirmationMail

func (m *TemplateMailer) ConfirmationMail(user *models.User, referrerURL string) error

ConfirmationMail sends a signup confirmation mail to a new user

func (*TemplateMailer) EmailChangeMail

func (m *TemplateMailer) EmailChangeMail(user *models.User, referrerURL string) error

EmailChangeMail sends an email change confirmation mail to a user

func (*TemplateMailer) InviteMail

func (m *TemplateMailer) InviteMail(user *models.User, referrerURL string) error

InviteMail sends a invite mail to a new user

func (*TemplateMailer) RecoveryMail

func (m *TemplateMailer) RecoveryMail(user *models.User, referrerURL string) 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