Help us shape the future of Go! Take the 2026 Go Developer Survey

postmark

package module
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 8 Imported by: 18

README

Postmark

Fork from Keighl's Postmark (A Golang package for the using Postmark API)

Go Build Status Go Report Card Release GoDoc


Installation
go get -u github.com/mrz1836/postmark

Basic Usage

Grab your Server Token, and your Account Token.

package main

import (
	"github.com/mrz1836/postmark"
)

func main() {
	client := postmark.NewClient("[SERVER-TOKEN]", "[ACCOUNT-TOKEN]")

	email := postmark.Email{
		From:       "no-reply@example.com",
		To:         "tito@example.com",
		Subject:    "Reset your password",
		HTMLBody:   "...",
		TextBody:   "...",
		Tag:        "pw-reset",
		TrackOpens: true,
	}

	_, err := client.SendEmail(email)
	if err != nil {
		panic(err)
	}
}

Swap out HTTPClient for use on Google App Engine:

package main

import (
    "github.com/mrz1836/postmark"
    "google.golang.org/appengine"
    "google.golang.org/appengine/urlfetch"
)

// ....

client := postmark.NewClient("[SERVER-TOKEN]", "[ACCOUNT-TOKEN]")

ctx := appengine.NewContext(req)
client.HTTPClient = urlfetch.Client(ctx)

// ...

API Coverage
  • Emails
    • POST /email
    • POST /email/batch
    • POST /email/withTemplate
    • POST /email/batchWithTemplates
  • Bounces
    • GET /deliverystats
    • GET /bounces
    • GET /bounces/:id
    • GET /bounces/:id/dump
    • PUT /bounces/:id/activate
    • GET /bounces/tags
  • Templates
    • GET /templates
    • POST /templates
    • GET /templates/:id
    • PUT /templates/:id
    • DELETE /templates/:id
    • POST /templates/validate
  • Servers
    • GET /servers/:id
    • PUT /servers/:id
  • Outbound Messages
    • GET /messages/outbound
    • GET /messages/outbound/:id/details
    • GET /messages/outbound/:id/dump
    • GET /messages/outbound/opens
    • GET /messages/outbound/opens/:id
  • Inbound Messages
    • GET /messages/inbound
    • GET /messages/inbound/:id/details
    • PUT /messages/inbound/:id/bypass
    • PUT /messages/inbound/:id/retry
  • Sender signatures
    • GET /senders
    • Get a sender signature’s details
    • Create a signature
    • Edit a signature
    • Delete a signature
    • Resend a confirmation
    • Verify an SPF record
    • Request a new DKIM
  • Stats
    • GET /stats/outbound
    • GET /stats/outbound/sends
    • GET /stats/outbound/bounces
    • GET /stats/outbound/spam
    • GET /stats/outbound/tracked
    • GET /stats/outbound/opens
    • GET /stats/outbound/platform
    • Get email client usage
    • Get email read times
  • Triggers
    • Tags triggers
      • Create a trigger for a tag
      • Get a single trigger
      • Edit a single trigger
      • Delete a single trigger
      • Search triggers
    • Inbound rules triggers
      • Create a trigger for inbound rule
      • Delete a single trigger
      • List triggers
Library Deployment

goreleaser for easy binary or library deployment to Github and can be installed via: brew install goreleaser.

The .goreleaser.yml file is used to configure goreleaser.

Use make release-snap to create a snapshot version of the release, and finally make release to ship to production.

Makefile Commands

View all makefile commands

make help

List of all current commands:

all                   Runs multiple commands
clean                 Remove previous builds and any test cache data
clean-mods            Remove all the Go mod cache
coverage              Shows the test coverage
diff                  Show the git diff
generate              Runs the go generate command in the base of the repo
godocs                Sync the latest tag with GoDocs
help                  Show this help message
install               Install the application
install-go            Install the application (Using Native Go)
install-releaser      Install the GoReleaser application
lint                  Run the golangci-lint application (install if not found)
release               Full production release (creates release in Github)
release               Runs common.release then runs godocs
release-snap          Test the full release (build binaries)
release-test          Full production test release (everything except deploy)
replace-version       Replaces the version in HTML/JS (pre-deploy)
run-examples          Runs all the examples
tag                   Generate a new tag and push (tag version=0.0.0)
tag-remove            Remove a tag if found (tag-remove version=0.0.0)
tag-update            Update an existing tag to current commit (tag-update version=0.0.0)
test                  Runs lint and ALL tests
test-ci               Runs all tests via CI (exports coverage)
test-ci-no-race       Runs all tests via CI (no race) (exports coverage)
test-ci-short         Runs unit tests via CI (exports coverage)
test-no-lint          Runs just tests
test-short            Runs vet, lint and tests (excludes integration tests)
test-unit             Runs tests and outputs coverage
uninstall             Uninstall the application (and remove files)
update-linter         Update the golangci-lint package (macOS only)
vet                   Run the Go vet application

Examples & Tests

All unit tests and examples run via Github Actions and uses Go version 1.15.x. View the configuration file.

Run all tests (including integration tests)

make test

Run tests (excluding integration tests)

make test-short

Run the examples:

make run-examples

License

License

Documentation

Overview

Package postmark ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	// ErrorCode: see error codes here (http://developer.postmarkapp.com/developer-api-overview.html#error-codes)
	ErrorCode int64
	// Message contains error details
	Message string
}

APIError represents errors returned by Postmark

func (APIError) Error

func (res APIError) Error() string

Error returns the error message details

type Attachment

type Attachment struct {
	// Name: attachment name
	Name string
	// Content: Base64 encoded attachment data
	Content string
	// ContentType: attachment MIME type
	ContentType string
	// ContentId: populate for inlining images with the images cid
	ContentID string `json:",omitempty"`
}

Attachment is an optional encoded file to send along with an email

type Bounce

type Bounce struct {
	// ID: ID of bounce
	ID int64
	// Type: Bounce type
	Type string
	// TypeCode: Bounce type code
	TypeCode int64
	// Name: Bounce type name
	Name string
	// Tag: Tag name
	Tag string
	// MessageID: ID of message
	MessageID string
	// Description: Description of bounce
	Description string
	// Details: Details on the bounce
	Details string
	// Email: Email address that bounced
	Email string
	// BouncedAt: Timestamp of bounce
	BouncedAt time.Time
	// DumpAvailable: Specifies whether or not you can get a raw dump from this bounce. Postmark does not store bounce dumps older than 30 days.
	DumpAvailable bool
	// Inactive: Specifies if the bounce caused Postmark to deactivate this email.
	Inactive bool
	// CanActivate: Specifies whether or not you are able to reactivate this email.
	CanActivate bool
	// Subject: Email subject
	Subject string
}

Bounce represents a specific delivery failure

type BounceCounts

type BounceCounts struct {
	// Days - List of objects that each represent sent counts by date.
	Days []BounceDay
	// HardBounce - total number of hard bounces
	HardBounce int64
	// SoftBounce - total number of soft bounces
	SoftBounce int64
	// SMTPApiError - total number of SMTP errors
	SMTPApiError int64
	// Transient - total number of transient bounces.
	Transient int64
}

BounceCounts - bounce stats for a period

type BounceDay

type BounceDay struct {
	// Date - self explanatory
	Date string
	// HardBounce - number of hard bounces
	HardBounce int64
	// SoftBounce - number of soft bounces
	SoftBounce int64
	// SMTPApiError - number of SMTP errors
	SMTPApiError int64
	// Transient - number of transient bounces.
	Transient int64
}

BounceDay - bounce stats for a specific day

type BounceType

type BounceType struct {
	// Type: bounce type identifier
	Type string
	// Name: full name of the bounce type
	Name string
	// Count: how many bounces have occurred
	Count int64
}

BounceType represents a type of bounce, and how many bounces have occurred http://developer.postmarkapp.com/developer-api-bounce.html#bounce-types

type Client

type Client struct {
	// HTTPClient is &http.Client{} by default
	HTTPClient *http.Client
	// Server Token: Used for requests that require server level privileges. This token can be found on the Credentials tab under your Postmark server.
	ServerToken string
	// AccountToken: Used for requests that require account level privileges. This token is only accessible by the account owner, and can be found on the Account tab of your Postmark account.
	AccountToken string
	// BaseURL is the root API endpoint
	BaseURL string
}

Client provides a connection to the Postmark API

func NewClient

func NewClient(serverToken string, accountToken string) *Client

NewClient builds a new Client pointer using the provided tokens, a default HTTPClient, and a default API base URL Accepts `Server Token`, and `Account Token` as arguments http://developer.postmarkapp.com/developer-api-overview.html#authentication

func (*Client) ActivateBounce

func (client *Client) ActivateBounce(bounceID int64) (Bounce, string, error)

ActivateBounce reactivates a bounce for resending. Returns the bounce, a message, and any error that occurs TODO: clarify this with Postmark

func (*Client) BypassInboundMessage

func (client *Client) BypassInboundMessage(messageID string) error

BypassInboundMessage - Bypass rules for a blocked inbound message

func (*Client) CreateTemplate

func (client *Client) CreateTemplate(template Template) (TemplateInfo, error)

CreateTemplate saves a new template to the server

func (*Client) DeleteTemplate

func (client *Client) DeleteTemplate(templateID string) error

DeleteTemplate removes a template (with templateID) from the server

func (*Client) EditCurrentServer

func (client *Client) EditCurrentServer(server Server) (Server, error)

EditCurrentServer updates details for the server associated with the currently in-use server API Key

func (*Client) EditServer

func (client *Client) EditServer(serverID string, server Server) (Server, error)

EditServer updates details for a specific server with serverID

func (*Client) EditTemplate

func (client *Client) EditTemplate(templateID string, template Template) (TemplateInfo, error)

EditTemplate updates details for a specific template with templateID

func (*Client) GetBounce

func (client *Client) GetBounce(bounceID int64) (Bounce, error)

GetBounce fetches a single bounce with bounceID

func (*Client) GetBounceCounts

func (client *Client) GetBounceCounts(options map[string]interface{}) (BounceCounts, error)

GetBounceCounts - Gets total counts of emails you’ve sent out that have been returned as bounced. Available options: http://developer.postmarkapp.com/developer-api-stats.html#bounce-counts

func (*Client) GetBounceDump

func (client *Client) GetBounceDump(bounceID int64) (string, error)

GetBounceDump fetches a SMTP data dump for a single bounce

func (*Client) GetBouncedTags

func (client *Client) GetBouncedTags() ([]string, error)

GetBouncedTags retrieves a list of tags that have generated bounced emails

func (*Client) GetBounces

func (client *Client) GetBounces(count int64, offset int64, options map[string]interface{}) ([]Bounce, int64, error)

GetBounces returns bounces for the server It returns a Bounce slice, the total bounce count, and any error that occurred Available options: http://developer.postmarkapp.com/developer-api-bounce.html#bounces

func (*Client) GetCurrentServer

func (client *Client) GetCurrentServer() (Server, error)

GetCurrentServer gets details for the server associated with the currently in-use server API Key

func (*Client) GetDeliveryStats

func (client *Client) GetDeliveryStats() (DeliveryStats, error)

GetDeliveryStats returns delivery stats for the server

func (*Client) GetInboundMessage

func (client *Client) GetInboundMessage(messageID string) (InboundMessage, error)

GetInboundMessage fetches a specific inbound message via serverID

func (*Client) GetInboundMessages

func (client *Client) GetInboundMessages(count int64, offset int64, options map[string]interface{}) ([]InboundMessage, int64, error)

GetInboundMessages fetches a list of inbound message on the server It returns a InboundMessage slice, the total message count, and any error that occurred http://developer.postmarkapp.com/developer-api-messages.html#inbound-message-search

func (*Client) GetOpenCounts

func (client *Client) GetOpenCounts(options map[string]interface{}) (OpenCounts, error)

GetOpenCounts - Gets total counts of recipients who opened your emails. This is only recorded when open tracking is enabled for that email. Available options: http://developer.postmarkapp.com/developer-api-stats.html#email-opens-count

func (*Client) GetOutboundMessage

func (client *Client) GetOutboundMessage(messageID string) (OutboundMessage, error)

GetOutboundMessage fetches a specific outbound message via serverID

func (*Client) GetOutboundMessageDump

func (client *Client) GetOutboundMessageDump(messageID string) (string, error)

GetOutboundMessageDump fetches the raw source of message. If no dump is available this will return an empty string.

func (*Client) GetOutboundMessageOpens

func (client *Client) GetOutboundMessageOpens(messageID string, count int64, offset int64) ([]Open, int64, error)

GetOutboundMessageOpens fetches a list of opens for a specific message It returns a Open slice, the total opens count, and any error that occurred

func (*Client) GetOutboundMessages

func (client *Client) GetOutboundMessages(count int64, offset int64, options map[string]interface{}) ([]OutboundMessage, int64, error)

GetOutboundMessages fetches a list of outbound message on the server It returns a OutboundMessage slice, the total message count, and any error that occurred Note: that a single open is bound to a single recipient, so if the same message was sent to two recipients and both of them opened it, that will be represented by two entries in this array. Available options: http://developer.postmarkapp.com/developer-api-messages.html#outbound-message-search

func (*Client) GetOutboundMessagesOpens

func (client *Client) GetOutboundMessagesOpens(count int64, offset int64, options map[string]interface{}) ([]Open, int64, error)

GetOutboundMessagesOpens fetches a list of opens on the server It returns a Open slice, the total opens count, and any error that occurred To get opens for a specific message, use GetOutboundMessageOpens() Available options: http://developer.postmarkapp.com/developer-api-messages.html#message-opens

func (*Client) GetOutboundStats

func (client *Client) GetOutboundStats(options map[string]interface{}) (OutboundStats, error)

GetOutboundStats - Gets a brief overview of statistics for all of your outbound email. Available options: http://developer.postmarkapp.com/developer-api-stats.html#overview

func (*Client) GetPlatformCounts

func (client *Client) GetPlatformCounts(options map[string]interface{}) (PlatformCounts, error)

GetPlatformCounts gets the email platform usage

func (*Client) GetSenderSignatures

func (client *Client) GetSenderSignatures(count, offset int64) (SenderSignaturesList, error)

GetSenderSignatures gets a list of sender signatures, limited by count and paged by offset

func (*Client) GetSentCounts

func (client *Client) GetSentCounts(options map[string]interface{}) (SendCounts, error)

GetSentCounts - Gets a total count of emails you’ve sent out. Available options: http://developer.postmarkapp.com/developer-api-stats.html#sent-counts

func (*Client) GetServer

func (client *Client) GetServer(serverID string) (Server, error)

GetServer fetches a specific server via serverID

func (*Client) GetSpamCounts

func (client *Client) GetSpamCounts(options map[string]interface{}) (SpamCounts, error)

GetSpamCounts - Gets a total count of recipients who have marked your email as spam. Days that did not produce statistics won’t appear in the JSON response. Available options: http://developer.postmarkapp.com/developer-api-stats.html#spam-complaints

func (*Client) GetTemplate

func (client *Client) GetTemplate(templateID string) (Template, error)

GetTemplate fetches a specific template via TemplateID

func (*Client) GetTemplates

func (client *Client) GetTemplates(count int64, offset int64) ([]TemplateInfo, int64, error)

GetTemplates fetches a list of templates on the server It returns a TemplateInfo slice, the total template count, and any error that occurred Note: TemplateInfo only returns a subset of template attributes, use GetTemplate(id) to retrieve all template info.

func (*Client) GetTrackedCounts

func (client *Client) GetTrackedCounts(options map[string]interface{}) (TrackedCounts, error)

GetTrackedCounts - Gets a total count of emails you’ve sent with open tracking enabled. Available options: http://developer.postmarkapp.com/developer-api-stats.html#email-tracked-count

func (*Client) RetryInboundMessage

func (client *Client) RetryInboundMessage(messageID string) error

RetryInboundMessage - Retry a failed inbound message for processing

func (*Client) SendEmail

func (client *Client) SendEmail(email Email) (EmailResponse, error)

SendEmail sends, well, an email.

func (*Client) SendEmailBatch

func (client *Client) SendEmailBatch(emails []Email) ([]EmailResponse, error)

SendEmailBatch sends multiple emails together Note, individual emails in the batch can error, so it would be wise to range over the responses and sniff for errors

func (*Client) SendTemplatedEmail

func (client *Client) SendTemplatedEmail(email TemplatedEmail) (EmailResponse, error)

SendTemplatedEmail sends an email using a template (TemplateID)

func (*Client) SendTemplatedEmailBatch

func (client *Client) SendTemplatedEmailBatch(emails []TemplatedEmail) ([]EmailResponse, error)

SendTemplatedEmailBatch sends batch email using a template (TemplateID)

func (*Client) ValidateTemplate

func (client *Client) ValidateTemplate(validateTemplateBody ValidateTemplateBody) (ValidateTemplateResponse, error)

ValidateTemplate validates the provided template/render model combination

type DeliveryStats

type DeliveryStats struct {
	// InactiveMails: Number of inactive emails
	InactiveMails int64
	// Bounces: List of bounce types with total counts.
	Bounces []BounceType
}

DeliveryStats represents bounce stats

type Email

type Email struct {
	// From: REQUIRED The sender email address. Must have a registered and confirmed Sender Signature.
	From string `json:",omitempty"`
	// To: REQUIRED Recipient email address. Multiple addresses are comma separated. Max 50.
	To string `json:",omitempty"`
	// Cc recipient email address. Multiple addresses are comma separated. Max 50.
	Cc string `json:",omitempty"`
	// Bcc recipient email address. Multiple addresses are comma separated. Max 50.
	Bcc string `json:",omitempty"`
	// Subject: Email subject
	Subject string `json:",omitempty"`
	// Tag: Email tag that allows you to categorize outgoing emails and get detailed statistics.
	Tag string `json:",omitempty"`
	// HTMLBody: HTML email message. REQUIRED, If no TextBody specified
	HTMLBody string `json:"HtmlBody,omitempty"`
	// TextBody: Plain text email message. REQUIRED, If no HTMLBody specified
	TextBody string `json:",omitempty"`
	// ReplyTo: Reply To override email address. Defaults to the Reply To set in the sender signature.
	ReplyTo string `json:",omitempty"`
	// Headers: List of custom headers to include.
	Headers []Header `json:",omitempty"`
	// TrackOpens: Activate open tracking for this email.
	TrackOpens bool `json:",omitempty"`
	// TrackLinks:Activate link tracking for links in the HTML or Text bodies of this email. Possible options: None HtmlAndText HtmlOnly TextOnly
	TrackLinks string `json:",omitempty"`
	// Attachments: List of attachments
	Attachments []Attachment `json:",omitempty"`
	// Metadata: metadata
	Metadata map[string]string `json:",omitempty"`
	// MessageStream: MessageStream will default to the outbound message stream ID (Default Transactional Stream) if no message stream ID is provided.
	MessageStream string `json:",omitempty"`
}

Email is exactly what it sounds like

type EmailResponse

type EmailResponse struct {
	// To: Recipient email address
	To string
	// SubmittedAt: Timestamp
	SubmittedAt time.Time
	// MessageID: ID of message
	MessageID string
	// ErrorCode: API Error Codes
	ErrorCode int64
	// Message: Response message
	Message string
}

EmailResponse holds info in response to a send/send-batch request Even if API request comes back successful, check the ErrorCode to see if there might be a delivery problem

type Header struct {
	// Name: header name
	Name string
	// Value: header value
	Value string
}

Header - an email header

type InboundMessage

type InboundMessage struct {
	// From - The sender email address.
	From string
	// FromName - The sender name.
	FromName string
	// FromFull - Sender email address and name.
	FromFull Recipient
	// To - Inbound address the message was sent to.
	To string
	// ToFull - Slice of all TO recipients
	ToFull []Recipient
	// CcFull - Slice of all CC recipients
	CcFull []Recipient
	// Cc - Cc recipient email address.
	Cc string
	// ReplyTo - Reply to override email address.
	ReplyTo string
	// OriginalRecipient - Receiver (RCPT TO) address this webhook is for.
	OriginalRecipient string
	// Subject - Email subject
	Subject string
	// Date - Timestamp
	Date string
	// MailboxHash - Custom hash that the email was sent to.
	MailboxHash string
	// TextBody - Plain text email message.
	TextBody string
	// HTMLBody - HTML email message.
	HTMLBody string `json:"HtmlBody"`
	// Tag - Tag name
	Tag string
	// Headers - List of objects that each represent a header name and value.
	Headers []Header
	// Attachments - List of objects that each represent an attachment.
	Attachments []Attachment
	// MessageID - Unique ID of the message.
	MessageID string
	// BlockedReason - Reason message was blocked.
	BlockedReason string
	// Status - Status of message in your Postmark activity.
	Status string
}

InboundMessage - a message received from the Postmark server

func (InboundMessage) Time

func (x InboundMessage) Time() (time.Time, error)

Time returns a parsed time.Time struct Inbound messages return as RFC1123Z strangely

type MessageEvent

type MessageEvent struct {
	// Recipient is who received the message (just email address)
	Recipient string
	// ReceivedAt is the event timestamp
	ReceivedAt time.Time
	// Type of event (Delivered, Opened, or Bounced)
	Type string
	// Details contain information regarding the event
	// http://developer.postmarkapp.com/developer-api-messages.html#outbound-message-details
	Details map[string]string
}

MessageEvent represents things that have happened to a message.

type Open

type Open struct {
	// FirstOpen - Indicates if the open was first open of message with MessageID and by Recipient. Any subsequent opens of the same message by the same Recipient will show false in this field. Postmark only saves first opens to its store, while all opens are available via Open web hooks.
	FirstOpen bool
	// UserAgent - Full user-agent header passed by the client software to Postmark. Postmark will fill in the Platform Client and OS fields based on this.
	UserAgent string
	// MessageID - Unique ID of the message.
	MessageID string
	// Client - Shows the email client (or browser) used to open the email. Name company and family are described in the parameters specification for this endpoint.
	Client map[string]string
	// OS - Shows the operating system used to open the email.
	OS map[string]string
	// Platform - Shows what platform was used to open the email. WebMail Desktop Mobile Unknown
	Platform string
	// ReadSeconds - Shows the reading time in seconds
	ReadSeconds int64
	// Geo - Contains IP of the recipient’s machine where the email was opened and the information based on that IP - geo coordinates (Coordinates) and country, region, city and zip.
	Geo map[string]string
}

Open represents a single email open.

type OpenCounts

type OpenCounts struct {
	// Days - List of objects that each represent opens by date.
	Days []OpenedDay
	// Opens - Indicates total number of opened emails. This total includes recipients who opened your email multiple times.
	Opens int64
	// Unique int64 - Indicates total number of uniquely opened emails.
	Unique int64
}

OpenCounts - opened outbound emails for a period

type OpenedDay

type OpenedDay struct {
	// Date - self explanatory
	Date string
	// Opens - Indicates total number of opened emails. This total includes recipients who opened your email multiple times.
	Opens int64
	// Unique - Indicates total number of uniquely opened emails.
	Unique int64
}

OpenedDay - opened outbound emails sent on a specific day

type OutboundMessage

type OutboundMessage struct {
	// TextBody - Text body of the message.
	TextBody string
	// HTMLBody - Html body of the message.
	HTMLBody string `json:"HtmlBody"`
	// Body - Raw source of the message.
	Body string
	// Tag - Tags associated with this message.
	Tag string
	// MessageID - Unique ID of the message.
	MessageID string
	// To - List of objects that contain To recipients.
	To []Recipient
	// Cc - List of objects that contain Cc recipients.
	Cc []Recipient
	// Bcc - List of objects that contain Bcc recipients.
	Bcc []Recipient
	// Recipients - List of recipients (just emails)
	Recipients []string
	// ReceivedAt - Timestamp
	ReceivedAt time.Time
	// From - The sender email address.
	From string
	// Subject - Email subject
	Subject string
	// Attachments - List of objects that each represent an attachment.
	Attachments []string
	// Status - Status of message in your Postmark activity.
	Status string
	// MessageEvents - List of summaries (MessageEvent) of things that have happened to this message. They can be Delivered, Opened, or Bounced as shown in the type field.
	MessageEvents []MessageEvent
}

OutboundMessage - a message sent from the Postmark server

type OutboundStats

type OutboundStats struct {
	// Sent - Number of sent emails
	Sent int64
	// Bounced - Number of bounced emails
	Bounced int64
	// SMTPApiErrors - Number of SMTP errors
	SMTPApiErrors int64
	// BounceRate - Bounce rate percentage calculated by total sent.
	BounceRate float64
	// SpamComplaints - Number of spam complaints received
	SpamComplaints int64
	// SpamComplaintsRate - Spam complaints percentage calculated by total sent.
	SpamComplaintsRate float64
	// Opens - Number of opens
	Opens int64
	// UniqueOpens - Number of unique opens
	UniqueOpens int64
	// Tracked - Number of tracked emails sent
	Tracked int64
	// WithClientRecorded - Number of emails where the client was successfully tracked.
	WithClientRecorded int64
	// WithPlatformRecorded - Number of emails where platform was successfully tracked.
	WithPlatformRecorded int64
	// WithReadTimeRecorded - Number of emails where read time was successfully tracked.
	WithReadTimeRecorded int64
}

OutboundStats - a brief overview of statistics for all of your outbound email.

type PlatformCounts

type PlatformCounts struct {
	// Days - List of objects that each represent email platform usages by date
	Days []PlatformDay
	// Desktop - The total number of email platform usages by Desktop
	Desktop int64

	// Mobile - The total number of email platform usages by Mobile
	Mobile int64

	// Unknown - The total number of email platform usages by others
	Unknown int64

	// WebMail - The total number of email platform usages by WebMail
	WebMail int64
}

PlatformCounts contains day-to-day usages, along with totals of email usages by platform

type PlatformDay

type PlatformDay struct {
	// Date - the date in question
	Date string

	// Desktop - The total number of email platform usages by Desktop for this date
	Desktop int64

	// Mobile - The total number of email platform usages by Mobile for this date
	Mobile int64

	// Unknown - The total number of email platform usages by others for this date
	Unknown int64

	// WebMail - The total number of email platform usages by WebMail for this date
	WebMail int64
}

PlatformDay contains the totals of email usages by platform for a specific date

type Recipient

type Recipient struct {
	// Name is the recipient's name
	Name string
	// Emails is the recipient's email address
	Email string
}

Recipient represents an individual who received a message

type SendCounts

type SendCounts struct {
	// Days - List of objects that each represent sent counts by date.
	Days []SendDay
	// Sent - Indicates the number of total sent emails returned.
	Sent int64
}

SendCounts - send stats for a period

type SendDay

type SendDay struct {
	// Date - self explanatory
	Date string
	// Sent - number of emails sent
	Sent int64
}

SendDay - send stats for a specific day

type SenderSignature

type SenderSignature struct {
	Domain              string
	EmailAddress        string
	ReplyToEmailAddress string
	Name                string
	Confirmed           bool
	ID                  int64
}

SenderSignature contains the details of the signature of the senders

type SenderSignaturesList

type SenderSignaturesList struct {
	TotalCount       int
	SenderSignatures []SenderSignature
}

SenderSignaturesList is just a list of SenderSignatures as they are in the response

type Server

type Server struct {
	// ID of server
	ID int64
	// Name of server
	Name string
	// APITokens associated with server.
	APITokens []string `json:"ApiTokens"`
	// ServerLink to your server overview page in Postmark.
	ServerLink string
	// Color of the server in the rack screen. Purple Blue Turquoise Green Red Yellow Grey
	Color string
	// SMTPAPIActivated specifies whether or not SMTP is enabled on this server.
	SMTPAPIActivated bool `json:"SmtpApiActivated"`
	// RawEmailEnabled allows raw email to be sent with inbound.
	RawEmailEnabled bool
	// InboundAddress is the inbound email address
	InboundAddress string
	// InboundHookURL to POST to every time an inbound event occurs.
	InboundHookURL string `json:"InboundHookUrl"`
	// BounceHookURL to POST to every time a bounce event occurs.
	BounceHookURL string `json:"BounceHookUrl"`
	// OpenHookURL to POST to every time an open event occurs.
	OpenHookURL string `json:"OpenHookUrl"`
	// PostFirstOpenOnly - If set to true, only the first open by a particular recipient will initiate the open webhook. Any
	// subsequent opens of the same email by the same recipient will not initiate the webhook.
	PostFirstOpenOnly bool
	// TrackOpens indicates if all emails being sent through this server have open tracking enabled.
	TrackOpens bool
	// InboundDomain is the inbound domain for MX setup
	InboundDomain string
	// InboundHash is the inbound hash of your inbound email address.
	InboundHash string
	// InboundSpamThreshold is the maximum spam score for an inbound message before it's blocked.
	InboundSpamThreshold int64
}

Server represents a server registered in your Postmark account

type SpamCounts

type SpamCounts struct {
	// Days - List of objects that each represent spam complaint counts by date.
	Days []SpamDay
	// SpamComplaint - Indicates total number of spam complaints.
	SpamComplaint int64
}

SpamCounts - spam complaints for a period

type SpamDay

type SpamDay struct {
	// Date - self explanatory
	Date string
	// SpamComplaint - number of spam complaints received
	SpamComplaint int64
}

SpamDay - spam complaints for a specific day

type Template

type Template struct {
	// TemplateID: ID of template
	TemplateID int64 `json:"TemplateID"`
	// Name: Name of template
	Name string
	// Subject: The content to use for the Subject when this template is used to send email.
	Subject string
	// HTMLBody: The content to use for the HTMLBody when this template is used to send email.
	HTMLBody string `json:"HtmlBody"`
	// TextBody: The content to use for the TextBody when this template is used to send email.
	TextBody string
	// AssociatedServerID: The ID of the Server with which this template is associated.
	AssociatedServerID int64 `json:"AssociatedServerId"`
	// Active: Indicates that this template may be used for sending email.
	Active bool
}

Template represents an email template on the server

type TemplateInfo

type TemplateInfo struct {
	// TemplateID: ID of template
	TemplateID int64 `json:"TemplateID"`
	// Name: Name of template
	Name string
	// Active: Indicates that this template may be used for sending email.
	Active bool
}

TemplateInfo is a limited set of template info returned via Index/Editing endpoints

type TemplatedEmail

type TemplatedEmail struct {
	// TemplateID: REQUIRED if TemplateAlias is not specified. - The template id to use when sending this message.
	TemplateID int64 `json:"TemplateId,omitempty"`
	// TemplateAlias: REQUIRED if TemplateID is not specified. - The template alias to use when sending this message.
	TemplateAlias string `json:",omitempty"`
	// TemplateModel: The model to be applied to the specified template to generate HtmlBody, TextBody, and Subject.
	TemplateModel map[string]interface{} `json:",omitempty"`
	// InlineCSS: By default, if the specified template contains an HtmlBody, we will apply the style blocks as inline attributes to the rendered HTML content. You may opt-out of this behavior by passing false for this request field.
	InlineCSS bool `json:"InlineCSS,omitempty"`
	// From: The sender email address. Must have a registered and confirmed Sender Signature.
	From string `json:",omitempty"`
	// To: REQUIRED Recipient email address. Multiple addresses are comma separated. Max 50.
	To string `json:",omitempty"`
	// Cc recipient email address. Multiple addresses are comma separated. Max 50.
	Cc string `json:",omitempty"`
	// Bcc recipient email address. Multiple addresses are comma separated. Max 50.
	Bcc string `json:",omitempty"`
	// Tag: Email tag that allows you to categorize outgoing emails and get detailed statistics.
	Tag string `json:",omitempty"`
	// Reply To override email address. Defaults to the Reply To set in the sender signature.
	ReplyTo string `json:",omitempty"`
	// Headers: List of custom headers to include.
	Headers []Header `json:",omitempty"`
	// TrackOpens: Activate open tracking for this email.
	TrackOpens bool `json:",omitempty"`
	// Attachments: List of attachments
	Attachments []Attachment `json:",omitempty"`
	// MessageStream: MessageStream will default to the outbound message stream ID (Default Transactional Stream) if no message stream ID is provided.
	MessageStream string `json:",omitempty"`
}

TemplatedEmail is used to send an email via a template

type TrackedCounts

type TrackedCounts struct {
	// Days - List of objects that each represent tracked email counts by date.
	Days []TrackedDay
	// Tracked - Indicates total number of tracked emails sent.
	Tracked int64
}

TrackedCounts - tracked emails sent for a period

type TrackedDay

type TrackedDay struct {
	// Date - self explanatory
	Date string
	// Tracked - number of emails tracked sent
	Tracked int64
}

TrackedDay - tracked emails sent on a specific day

type ValidateTemplateBody

type ValidateTemplateBody struct {
	Subject                    string
	TextBody                   string
	HTMLBody                   string `json:"HTMLBody"`
	TestRenderModel            map[string]interface{}
	InlineCSSForHTMLTestRender bool `json:"InlineCssForHtmlTestRender"`
}

ValidateTemplateBody contains the template/render model combination to be validated

type ValidateTemplateResponse

type ValidateTemplateResponse struct {
	AllContentIsValid      bool
	HTMLBody               Validation `json:"HTMLBody"`
	TextBody               Validation
	Subject                Validation
	SuggestedTemplateModel map[string]interface{}
}

ValidateTemplateResponse contains information as to how the validation went

type Validation

type Validation struct {
	ContentIsValid   bool
	ValidationErrors []ValidationError
	RenderedContent  string
}

Validation contains the results of a field's validation

type ValidationError

type ValidationError struct {
	Message           string
	Line              int
	CharacterPosition int
}

ValidationError contains information about the errors which occurred during validation for a given field

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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