mailer

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: Apache-2.0 Imports: 19 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 {
	ConfirmationMail(email, password string) error
}

Mailer defines the interface a mailer must implement.

func NewMailer

func NewMailer(instanceConfig *config.Configuration) Mailer

NewMailer returns a new 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  *config.Configuration
	Mailer  *MailmeMailer
}

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

func (*TemplateMailer) ConfirmationMail added in v0.2.4

func (m *TemplateMailer) ConfirmationMail(email, password string) error

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