mandrill

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SendTo  SendType = "to"
	SendCC           = "cc"
	SendBCC          = "bcc"
)
View Source
const (
	MessageSent      SendStatus = "sent"
	MessageQueued               = "queued"
	MessageScheduled            = "scheduled"
	MessageRejected             = "rejected"
	MessageInvalid              = "invalid"
	ClientError                 = "error"
)
View Source
const (
	RejectedHardBounce    RejectType = "hard-bounce"
	RejectedSoftBounce               = "soft-bounce"
	RejectedSpam                     = "spam"
	RejectedUnsub                    = "unsub"
	RejectedCustom                   = "custom"
	RejectedInvalidSender            = "invalid-sender"
	RejectedInvalid                  = "invalid"
	RejectedModeLimit                = "test-mode-limit"
	RejectedRule                     = "rule"
)
View Source
const (
	DateFormat string = "2006-01-02 15:04:05"
)
View Source
const ENDPOINT string = "https://mandrillapp.com/api/1.0/%s.json"

Variables

This section is empty.

Functions

func FormatEmail

func FormatEmail(m mail.Address) string

func FormatTime

func FormatTime(t time.Time) string

Types

type Attachment

type Attachment struct {
	Type    string `json:"type"`
	Name    string `json:"name"`
	Content string `json:"content"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(key string) *Client

func (*Client) Call

func (c *Client) Call(endpoint string, data map[string]interface{}, results interface{}) error

func (*Client) MessagesSend

func (p *Client) MessagesSend(msg *Message, opts ...SendOpt) ([]SendResult, error)

func (*Client) MessagesSendTemplate

func (p *Client) MessagesSendTemplate(name string, content []Variable, msg *Message, opts ...SendOpt) ([]SendResult, error)

func (*Client) Ping

func (p *Client) Ping() (bool, error)

func (*Client) TemplatesInfo

func (p *Client) TemplatesInfo(name string) (Template, error)

func (*Client) TemplatesList

func (p *Client) TemplatesList(label string) ([]Template, error)

func (*Client) TemplatesRender

func (p *Client) TemplatesRender(name string, content []Variable, vars []Variable) (interface{}, error)
func (p *Client) TemplatesTimeSeries() (interface{}, error) {
	return p.call("user", "info", nil)
}

type ErrorResult

type ErrorResult struct {
	Status  SendStatus `json:"status"`
	Code    int        `json:"code"`
	Name    string     `json:"name"`
	Message string     `json:"message"`
}

func (*ErrorResult) Error

func (e *ErrorResult) Error() string

type MergeLanguage

type MergeLanguage string
const (
	Mailchimp  MergeLanguage = "mailchimp"
	Handlebars               = "handlebars"
)

type Message

type Message struct {
	Html string `json:"html,omitempty"`
	Text string `json:"text,omitempty"`

	Subject   string `json:"subject,omitempty"`
	FromEmail string `json:"from_email,omitempty"`
	FromName  string `json:"from_name,omitempty"`

	Headers map[string]string `json:"headers,omitempty"`

	Important          bool `json:"important,omitempty"`
	TrackOpens         bool `json:"track_opens,omitempty"`
	TrackClicks        bool `json:"track_clicks,omitempty"`
	AutoText           bool `json:"auto_text,omitempty"`
	AutoHtml           bool `json:"auto_html,omitempty"`
	InlineCSS          bool `json:"inline_css,omitempty"`
	UrlStripQs         bool `json:"url_strip_qs,omitempty"`
	PreserveRecipients bool `json:"preserve_recipients,omitempty"`
	ViewContentLink    bool `json:"view_content_link,omitempty"`

	BCCAddress       string        `json:"bcc_address,omitempty"`
	TrackingDomain   string        `json:"tracking_domain,omitempty"`
	SigningDomain    string        `json:"signing_domain,omitempty"`
	ReturnPathDomain string        `json:"return_path_domain,omitempty"`
	Merge            bool          `json:"merge,omitempty"`
	MergeLanguage    MergeLanguage `json:"merge_language,omitempty"`

	GlobalMergeVars []Variable `json:"global_merge_vars,omitempty"`

	Tags                    []string       `json:"tags,omitempty"`
	SubAccount              string         `json:"sub_account,omitempty"`
	GoogleAnalyticsDomains  []string       `json:"google_analytics_domains,omitempty"`
	GoogleAnalyticsCampaign []string       `json:"google_analytics_campaign,omitempty"`
	Metadata                []RcptMetadata `json:"metadata,omitempty"`

	Recipients []Recipient `json:"to,omitempty"`
	// built from Recipients
	MergeVars         []RcptMergeVars `json:"merge_vars,omitempty"`
	RecipientMetadata []RcptMetadata  `json:"recipient_metadata,omitempty"`

	Attachments []Attachment `json:"attachments,omitempty"`
	Images      []Attachment `json:"images,omitempty"`
}

func NewMessage

func NewMessage() *Message

func (*Message) AddRecipient

func (m *Message) AddRecipient(t SendType, r Recipient) *Message

func (*Message) BCC added in v0.2.0

func (m *Message) BCC(email string, name string) *Message

func (*Message) CC added in v0.2.0

func (m *Message) CC(email string, name string) *Message

func (*Message) To

func (m *Message) To(email string, name string) *Message

func (*Message) WithValue added in v0.2.0

func (m *Message) WithValue(key string, content interface{}) *Message

func (*Message) WithValues added in v0.2.0

func (m *Message) WithValues(vals map[string]interface{}) *Message

type RcptMergeVars

type RcptMergeVars struct {
	Rcpt string     `json:"rcpt"`
	Vars []Variable `json:"vars"`
}

type RcptMetadata

type RcptMetadata struct {
	Rcpt   string            `json:"rcpt"`
	Values map[string]string `json:"values"`
}

type Recipient

type Recipient struct {
	Email     string            `json:"email"`
	Name      string            `json:"name,omitempty"`
	Type      SendType          `json:"type,omitempty"`
	MergeVars []Variable        `json:"-"`
	Metadata  map[string]string `json:"-"`
}

type RejectType

type RejectType string

type SendOpt added in v0.2.0

type SendOpt func(map[string]interface{})

func Async added in v0.2.0

func Async(val bool) SendOpt

func IPPool added in v0.2.0

func IPPool(val string) SendOpt

func SendAt added in v0.2.0

func SendAt(val string) SendOpt

type SendResult

type SendResult struct {
	Email        string     `json:"email"`
	Status       SendStatus `json:"status"`
	RejectReason RejectType `json:"reject_reason"`
	Id           string     `json:"id"`
}

type SendStatus

type SendStatus string

type SendType

type SendType string

type Template

type Template struct {
	Slug   string   `json:"slug,omitempty"`
	Name   string   `json:"name"`
	Labels []string `json:"labels,omitempty"`

	Code string `json:"code,omitempty"`

	Subject   string `json:"subject,omitempty"`
	FromEmail string `json:"from_email,omitempty"`
	FromName  string `json:"from_name,omitempty"`

	Text string `json:"text,omitempty"`

	PublishCode      string `json:"publish_code,omitempty"`
	PublishSubject   string `json:"publish_subject,omitempty"`
	PublishFromEmail string `json:"publish_from_email,omitempty"`
	PublishFromName  string `json:"publish_from_name,omitempty"`
	PublishText      string `json:"publish_text,omitempty"`

	PublishedAt string `json:"published_at,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
	Publish     bool   `json:"publish,omitempty"`
}

type Variable

type Variable struct {
	Name    string      `json:"name"`
	Content interface{} `json:"content"`
}

Jump to

Keyboard shortcuts

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