postmark

package module
v0.0.0-...-4687a0a Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2018 License: MIT Imports: 14 Imported by: 0

README

Build Status

postmark is a golang client for Postmark.

It support the following API endpoints:

  • Email API - for sending email.
  • Server API - for getting server status - also useful for testing client configuration.

It also has a simple worker queue implementation for async sending emails.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Name string
	File *os.File
}

Attachment is a Message attachnment backed by a file

type Client

type Client struct {
	Token       string
	FromAddress string

	BaseURL   *url.URL
	UserAgent string
	// contains filtered or unexported fields
}

Client is a postmark client

func NewClient

func NewClient(token string, fromaddr string) *Client

NewClient creates a new postmark client

func (*Client) SendMessage

func (c *Client) SendMessage(msg *Message) (*Response, error)

SendMessage sends a postmark message

func (*Client) SendTemplate

func (c *Client) SendTemplate(templateID int, to string, model interface{}) (*Response, error)

SendTemplate sends a postmark template

type Dispatcher

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

Dispatcher is a worker queue

func NewDispatcher

func NewDispatcher(maxworkers int, client *Client) *Dispatcher

NewDispatcher creates a new dispater with workers

func (*Dispatcher) Add

func (d *Dispatcher) Add(m *Message)

Add adds a new task to the queue

func (*Dispatcher) Run

func (d *Dispatcher) Run()

Run starts the dispatcher

type Message

type Message struct {
	Subject     string
	HTMLBody    string
	TextBody    string
	To          []*mail.Address
	Attachments []*Attachment
}

Message is an email message

func NewMessage

func NewMessage() *Message

NewMessage creates a new mail message

func (*Message) AddAttachment

func (m *Message) AddAttachment(name string, filename string) error

AddAttachment is a helper to add a file attachment to an email

func (*Message) AddTo

func (m *Message) AddTo(address string) error

AddTo adds a new recipient to the message

type Response

type Response struct {
	To          string
	SubmittedAt time.Time
	MessageID   string
	ErrorCode   int
	Message     string
}

Response is recieved by postmark when an email is submitted for sending

Jump to

Keyboard shortcuts

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