email

package
v0.0.0-...-b44aec9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultMailer is the mailer used.
	DefaultMailer Mailer
	// DefaultTemplateBuilder is used to generate templates
	DefaultTemplateBuilder TemplateBuilder
)

Functions

This section is empty.

Types

type Mailer

type Mailer interface {
	// Send a message.
	Send(dest string, subject string, text []byte, html []byte) error
}

Mailer sends Messages.

type MarkdownBuilder

type MarkdownBuilder struct {
	Provider MarkdownProvider
}

MarkdownBuilder generates email templates from markdown.

func NewMarkdownBuilder

func NewMarkdownBuilder(provider MarkdownProvider) *MarkdownBuilder

NewMarkdownBuilder creates a new MarkdownBuilder from a Provider.

func (*MarkdownBuilder) HTML

func (b *MarkdownBuilder) HTML(template, lang string, data interface{}) ([]byte, error)

HTML generates an HTML body.

func (*MarkdownBuilder) Text

func (b *MarkdownBuilder) Text(template, lang string, data interface{}) ([]byte, error)

Text generates an email text body.

type MarkdownProvider

type MarkdownProvider interface {
	// Get the markdown template by name and language (returns *text/template.Template).
	Get(templateName, lang string) (*text.Template, error)
	// Body for html messages by language (returns *html/template.Template).
	Body(lang string) (*html.Template, error)
}

MarkdownProvider provides templates for markdown Builder.

type Message

type Message struct {
	Dest     user.User   `json:"dest"`
	Subject  string      `json:"subject"`
	Template string      `json:"template"`
	Data     interface{} `json:"data"`
}

Message represents an email to be sent.

func (Message) Send

func (msg Message) Send() error

Send a Message

type SMTP

type SMTP struct {
	Host     string
	Port     int
	User     string
	Password string
	Sender   string
}

SMTP can send email through the SMTP protocol

func (SMTP) Send

func (s SMTP) Send(dest string, subject string, text []byte, html []byte) error

Send an email

type TemplateBuilder

type TemplateBuilder interface {
	// GenerateText for data in language lang
	Text(template, lang string, data interface{}) ([]byte, error)
	// GenerateHTML for data in language lang
	HTML(template, lang string, data interface{}) ([]byte, error)
}

TemplateBuilder generates the content of a Message.

Jump to

Keyboard shortcuts

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