Documentation ¶
Overview ¶
Package message implements the mailgun message convention.
Index ¶
- Constants
- type Message
- func (m *Message) BCC(bcc ...string) ([]string, error)
- func (m *Message) CC(cc ...string) ([]string, error)
- func (m *Message) Send(c client.Caller) (*Response, error)
- func (r *Message) SetRecipVars(m map[string]map[string]interface{})
- func (m *Message) TmpSend(c client.Caller) (*Response, error)
- func (m *Message) To(to ...string) ([]string, error)
- type Response
- type TrackOption
- Bugs
Constants ¶
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 ¶
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 ¶
BCC sets the "bcc" recipients of Message, returning the previous list or error if total > 1000.
func (*Message) CC ¶
CC sets the "cc" recipients of Message, returning the previous list or error if total > 1000.
func (*Message) SetRecipVars ¶
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.