maily

package
v0.0.0-...-6d844d4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = errors.New("maily: required parameter not set in Context")

ErrInvalidConfig is reported when a required parameter was not set in the Context.

View Source
var ErrTemplateMissing = errors.New("maily: couldn't find requested template")

ErrTemplateMissing is reported when the requested template could not be found.

View Source
var ErrTemplateMissingFile = errors.New("maily: requested template is missing files")

ErrTemplateMissingFile is reported when the requested template was missing a required file.

Functions

This section is empty.

Types

type Context

type Context struct {
	// The email address to send from
	FromAddress string

	// The from name, for example: "John Smith <jsmith@example.com>"
	FromDisplay string

	// The domain emails are being sent from (used to generate a Message-ID)
	SendDomain string

	// SMTP credentials, used to send the email
	SMTPHost     string
	SMTPPort     int
	SMTPUsername string
	SMTPPassword string

	// The path to the template folder. Can be relative or absolute.
	TemplatePath string
}

A Context contains information on how Maily should send emails. It is goroutine-safe. (that is, it may be accessed from multiple goroutines at the same time)

func (*Context) SendMail

func (c *Context) SendMail(toName string, toEmail string, templateName string, data TemplateData, textFuncs FuncMap, htmlFuncs FuncMap) (EmailResult, error)

SendMail sends an email to the given email address, using the given template and data.

type EmailResult

type EmailResult struct {
	// The value of the Message-ID header.
	MessageID string `json:"messageID"`
}

An EmailResult struct contains information about an email that was sent successfully.

type FuncMap

type FuncMap map[string]interface{}

A FuncMap is a list of functions that can be used within a template.

type TemplateData

type TemplateData map[string]interface{}

A TemplateData map holds information used in a template.

Jump to

Keyboard shortcuts

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