mail

package
v0.0.0-...-e8aac16 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2014 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewLine string = "\r\n"

Functions

func Send

func Send(c *smtp.Client, message *Message) (err error)

Send send message through the client

func Transport

func Transport(address string, port int, host string, a smtp.Auth) (*smtp.Client, error)

Transport initialize the smtp client

Types

type MailSender

type MailSender interface {
	SendMessage(messages ...*Message) (err error)
}

type Mailer

type Mailer struct {
	Server   string
	Port     int
	UserName string
	Password string
	Host     string    // This is optional, only used if you want to tell smtp server your hostname
	Auth     smtp.Auth // This is optional, only used if Authentication is not plain
	Sender   *Sender   // This is optional, only used if the From/ReplyTo is not specified in the message
}

func (*Mailer) SendMessage

func (m *Mailer) SendMessage(messages ...*Message) (err error)

Send the given email messages using this Mailer.

type Message

type Message struct {
	From      string
	ReplyTo   string
	To        []string
	Cc        []string
	Bcc       []string
	Subject   string
	PlainBody *bytes.Buffer
	HtmlBody  *bytes.Buffer

	Date      time.Time
	MessageId string
}

func NewHtmlMessage

func NewHtmlMessage(to []string, subject string, body string) *Message

NewHtmlMessage create a html message

func NewTextAndHtmlMessage

func NewTextAndHtmlMessage(to []string, subject string, plainBody string, htmlBody string) *Message

NewTextAndHtmlMessage create a message contains both plain text and html message

func NewTextMessage

func NewTextMessage(to []string, subject string, body string) *Message

NewTextMessage create a plain text message

func (*Message) RenderData

func (m *Message) RenderData() (data []byte, err error)

RenderData render the whole email body

func (*Message) RenderTemplate

func (m *Message) RenderTemplate(templatePath string, args map[string]interface{}) error

RenderTemplate renders the message body from the template and input parameters

type Sender

type Sender struct {
	From    string
	ReplyTo string
}

Jump to

Keyboard shortcuts

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