postmark

package
v0.0.0-...-6204e04 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package postmark provides a convenient wrapper for the Postmark API

Index

Examples

Constants

View Source
const (
	DefaultHost = "api.postmarkapp.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Name        string
	Content     io.Reader
	ContentType string
}

func (*Attachment) MarshalJSON

func (a *Attachment) MarshalJSON() ([]byte, error)

type Client

type Client struct {
	ApiKey string
	Secure bool

	Host string // Host for the API endpoints, DefaultHost if ""
}
Example
package main

import (
	"fmt"
	"net/mail"
	"strings"

	"github.com/hjr265/postmark.go/postmark"
)

func main() {
	c := postmark.Client{
		ApiKey: "YOUR-API-KEY",
		Secure: true,
	}

	res, err := c.Send(&postmark.Message{
		From: &mail.Address{
			Name:    "SENDER-NAME",
			Address: "SENDER-EMAIL",
		},
		To: []*mail.Address{
			{
				Name:    "RECIPIENT NAME",
				Address: "RECIPIENT EMAIL",
			},
		},
		Subject:  "SUBJECT",
		TextBody: strings.NewReader("MESSAGE-BODY-AS-TEXT"),
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("%#v\n", res)
}
Output:

func (*Client) Send

func (c *Client) Send(msg *Message) (*Result, error)

Send sends a single message

func (*Client) SendBatch

func (c *Client) SendBatch(msg []*Message) ([]*Result, error)

SendBatch sends multiple messages using the batch API

type Message

type Message struct {
	From          *mail.Address
	To            []*mail.Address
	Cc            []*mail.Address
	Bcc           []*mail.Address
	Subject       string
	Tag           string
	HtmlBody      io.Reader
	TextBody      io.Reader
	TemplateId    int
	TemplateModel map[string]interface{}
	ReplyTo       *mail.Address
	Headers       mail.Header
	Attachments   []Attachment
	TrackOpens    bool
	TrackLinks    bool
}

func (*Message) MarshalJSON

func (m *Message) MarshalJSON() ([]byte, error)

type Result

type Result struct {
	ErrorCode   int
	Message     string
	MessageID   string
	SubmittedAt string
	To          string
}

Jump to

Keyboard shortcuts

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