message

package
v0.0.0-...-8c17a97 Latest Latest
Warning

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

Go to latest
Published: May 28, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package message implements the mailgun message convention.

Index

Constants

View Source
const (
	Track    = trackoption(`yes`)
	NoTrack  = trackoption(`no`)
	HTMLOnly = trackoption(`htmlonly`)
)

TrackOptions

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Subject       string
	Text          string
	HTML          string
	Attachments   map[string]io.Reader
	Inlines       map[string]io.Reader
	Tag           string
	DKIM          *bool // this doesn't seem to have an associated domain API endpoint.
	DeliveryTime  *time.Time
	TestMode      *bool
	Tracking      *bool
	OpenTracking  *bool
	ClickTracking TrackOption
	RequireTLS    *bool
	SkipVerify    *bool
	Headers       textproto.MIMEHeader // keys will be canonicalized.
	Vars          map[string]string
	// contains filtered or unexported fields
}

Message is an email message. Methods with slice parameters do not retain references to those slices.

func New

func New(from, subject, html string, to ...string) (*Message, error)

New returns a *Message with from, subject, and html content. If len(to) > 1000 an error is returned. Vars, Headers, Attachments and Inlines maps are initialized.

func (*Message) BCC

func (m *Message) BCC(bcc ...string) ([]string, error)

BCC sets the "bcc" recipients of Message, returning the previous list or error if total > 1000.

func (*Message) CC

func (m *Message) CC(cc ...string) ([]string, error)

CC sets the "cc" recipients of Message, returning the previous list or error if total > 1000.

func (*Message) Send

func (m *Message) Send(c client.Caller) (*Response, error)

Send sends m, buffering in memory.

func (*Message) SetRecipVars

func (r *Message) SetRecipVars(m map[string]map[string]interface{})

func (*Message) TmpSend

func (m *Message) TmpSend(c client.Caller) (*Response, error)

TmpSend sends m, buffering to disk.

func (*Message) To

func (m *Message) To(to ...string) ([]string, error)

To sets the "to" recipients of Message, returning the previous list or error if total > 1000.

type Response

type Response struct {
	ID string `json:"id"`
}

Response is a response to a Send request.

type TrackOption

type TrackOption interface {
	// contains filtered or unexported methods
}

TrackOption is the interface shared by tracking options.

Notes

Bugs

  • Message.Vars is a little problematic. The relevant documentation at https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages is at best unclear. Empirically JSON-formatted strings with an ASCII character set appear to work well, callers may want to test other Message.Vars payload for potential astonishments.

  • In general the endpoint does an OK job inferring MIME headers from Inline and Attachment payload. A map was chosen because although the endpoint may support attachments with duplicate filenames (and IDs for attachments) difficulties may present themselves with duplicates with the same content disposition.

Directories

Path Synopsis
Package batch implements the batch mailing convention.
Package batch implements the batch mailing convention.

Jump to

Keyboard shortcuts

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