postmark

package
v0.0.0-...-0941746 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBroadcastStreamID     = "broadcast"
	DefaultInboundStreamID       = "inbound"
	DefaultTransactionalStreamID = "outbound"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	ErrorCode int64
	Message   string
}

func (APIError) Error

func (res APIError) Error() string

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"`
}

type Client

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

func NewClient

func NewClient(accountApiToken string, httpClient *http.Client) *Client

func (*Client) CreateDomain

func (client *Client) CreateDomain(ctx context.Context, input CreateDomainInput) (DetailedDomain, error)

func (*Client) CreateServer

func (client *Client) CreateServer(ctx context.Context, server Server) (Server, error)

func (*Client) DeleteDomain

func (client *Client) DeleteDomain(ctx context.Context, domainID string) error

func (*Client) DeleteServer

func (client *Client) DeleteServer(ctx context.Context, serverID string) (err error)

func (*Client) EditServer

func (client *Client) EditServer(ctx context.Context, serverID string, server Server) (Server, error)

func (*Client) GetDomain

func (client *Client) GetDomain(ctx context.Context, domainID string) (DetailedDomain, error)

func (*Client) GetDomains

func (client *Client) GetDomains(ctx context.Context, count, offset int64) (DomainsList, error)

func (*Client) GetServer

func (client *Client) GetServer(ctx context.Context, serverID string) (Server, error)

func (*Client) SendEmail

func (client *Client) SendEmail(ctx context.Context, serverToken string, email Email) (EmailResponse, error)

func (*Client) SendEmailsBatch

func (client *Client) SendEmailsBatch(ctx context.Context, serverToken string, emails []Email) ([]EmailResponse, error)

TODO: handle individual errors in []EmailResponse?

func (*Client) UpdateDomain

func (client *Client) UpdateDomain(ctx context.Context, domainID string, input UpdateDomainInput) (DetailedDomain, error)

func (*Client) UpdateMessageStream

func (client *Client) UpdateMessageStream(ctx context.Context, serverToken, messageStreamID string, input UpdateMessageStreamInput) (res MessageStream, err error)

func (*Client) VerifyDKIMStatus

func (client *Client) VerifyDKIMStatus(ctx context.Context, domainID string) (DetailedDomain, error)

func (*Client) VerifyReturnPathStatus

func (client *Client) VerifyReturnPathStatus(ctx context.Context, domainID string) (DetailedDomain, error)

type CreateDomainInput

type CreateDomainInput struct {
	// Domain name
	Name string
	// A custom value for the Return-Path domain. It is an optional field, but it must be a subdomain of your From Email domain and must have a CNAME record that points to pm.mtasv.net. For more information about this field, please read our support page.
	ReturnPathDomain string `json:",omitempty"`
}

type DetailedDomain

type DetailedDomain struct {
	// Unique ID of the Domain.
	ID int64
	// Domain name
	Name string
	// DEPRECATED: See our [blog post](https://postmarkapp.com/blog/why-we-no-longer-ask-for-spf-records) to learn why this field was deprecated.
	SPFVerified bool
	// Host name used for the SPF configuration.
	SPFHost string
	// Value that must be setup at your domain registrar or DNS host in order for SPF to function correctly.
	SPFTextValue string
	// DKIM DNS text record has been setup correctly at your domain registrar or DNS host.
	DKIMVerified bool
	// DKIM is using a strength weaker than 1024 bit. If so, it’s possible to request a new DKIM using the RequestNewDKIM function below.
	WeakDKIM bool
	// DNS TXT host being used to validate messages sent in.
	DKIMHost string
	// DNS TXT value being used to validate messages sent in.
	DKIMTextValue string
	// If a DKIM rotation has been intiated or this DKIM is from a new Domain, this field will show the pending DKIM DNS TXT host which has yet to be setup and confirmed at your registrar or DNS host.
	DKIMPendingHost string
	// Similar to the DKIMPendingHost field, this will show the DNS TXT value waiting to be confirmed at your registrar or DNS host.
	DKIMPendingTextValue string
	// Once a new DKIM has been confirmed at your registrar or DNS host, Postmark will revoke the old DKIM host in preparation for removing it permantly from the system.
	DKIMRevokedHost string
	// Similar to DKIMRevokedHost, this field will show the DNS TXT value that will soon be removed from the Postmark system.
	DKIMRevokedTextValue string
	// Indicates whether you may safely delete the old DKIM DNS TXT records at your registrar or DNS host. The new DKIM is now safely in use.
	SafeToRemoveRevokedKeyFromDNS bool
	// While DKIM renewal or new DKIM operations are being conducted or setup, this field will indicate Pending. After all DNS TXT records are up to date and any pending renewal operations are finished, it will indicate Verified.
	DKIMUpdateStatus string
	// The custom Return-Path for this domain, please read our support page.
	ReturnPathDomain string
	// The verification state of the Return-Path domain. Tells you if the Return-Path is actively being used or still needs further action to be used.
	ReturnPathDomainVerified bool
	// The CNAME DNS record that Postmark expects to find at the ReturnPathDomain value.
	ReturnPathDomainCNAMEValue string
}

type Domain

type Domain struct {
	// Unique ID of the Domain.
	ID int64
	// Domain name
	Name string
	// DEPRECATED: See our [blog post](https://postmarkapp.com/blog/why-we-no-longer-ask-for-spf-records) to learn why this field was deprecated.
	SPFVerified bool
	// DKIM DNS text record has been setup correctly at your domain registrar or DNS host.
	DKIMVerified bool
	// DKIM is using a strength weaker than 1024 bit. If so, it’s possible to request a new DKIM using the RequestNewDKIM function below.
	WeakDKIM bool
	// The verification state of the Return-Path domain. Tells you if the Return-Path is actively being used or still needs further action to be used.
	ReturnPathDomainVerified bool
}

type DomainsList

type DomainsList struct {
	TotalCount int
	Domains    []Domain
}

type Email

type Email struct {
	// From: REQUIRED The sender email address. Must have a registered and confirmed Sender Signature.
	From string
	// To: REQUIRED Recipient email address. Multiple addresses are comma separated. Max 50.
	To string
	// 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:",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"`
	// Attachments: List of attachments
	Attachments []Attachment `json:",omitempty"`
	// Metadata: Custom metadata key/value pairs.
	Metadata map[string]string `json:",omitempty"`
	// Set message stream ID that's used for sending. If not provided, message will default to the "outbound" transactional stream.
	MessageStream string
}

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
}
type Header struct {
	// Name: header name
	Name string
	// Value: header value
	Value string
}

type MessageStream

type MessageStream struct {
	ID                string            `json:"ID"`
	ServerID          int64             `json:"ServerID"`
	Name              string            `json:"Name"`
	Description       string            `json:"Description"`
	MessageStreamType MessageStreamType `json:"MessageStreamType"`
	// 	"CreatedAt": "2020-07-02T00:00:00-04:00",
	// 	"UpdatedAt": "2020-07-03T00:00:00-04:00",
	// 	"ArchivedAt": null,
	// 	"ExpectedPurgeDate": null,
	SubscriptionManagementConfiguration MessageStreamSubscriptionManagementConfiguration `json:"SubscriptionManagementConfiguration"`
}

See https://postmarkapp.com/developer/api/message-streams-api

type MessageStreamSubscriptionManagementConfiguration

type MessageStreamSubscriptionManagementConfiguration struct {
	UnsubscribeHandlingType MessageStreamUnsubscribeHandlingType `json:"UnsubscribeHandlingType"`
}

type MessageStreamType

type MessageStreamType string
const (
	MessageStreamTypeInbound       MessageStreamType = "Inbound"
	MessageStreamTypeBroadcasts    MessageStreamType = "Broadcasts"
	MessageStreamTypeTransactional MessageStreamType = "Transactional"
)

type MessageStreamUnsubscribeHandlingType

type MessageStreamUnsubscribeHandlingType string
const (
	MessageStreamUnsubscribeHandlingPostmark MessageStreamUnsubscribeHandlingType = "Postmark"
	MessageStreamUnsubscribeHandlingCustom   MessageStreamUnsubscribeHandlingType = "Custom"
	MessageStreamUnsubscribeHandlingNone     MessageStreamUnsubscribeHandlingType = "none"
)

type Server

type Server struct {
	// ID of server
	ID int64 `json:",omitempty"`
	// Name of server
	Name string
	// ApiTokens associated with server.
	ApiTokens []string `json:",omitempty"`
	// ServerLink to your server overview page in Postmark.
	ServerLink string `json:",omitempty"`
	// 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
	// RawEmailEnabled allows raw email to be sent with inbound.
	RawEmailEnabled bool
	// InboundAddress is the inbound email address
	InboundAddress string `json:",omitempty"`
	// InboundHookUrl to POST to every time an inbound event occurs.
	InboundHookUrl string
	// 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
}

type UpdateDomainInput

type UpdateDomainInput struct {
	// A custom value for the Return-Path domain. It is an optional field, but it must be a subdomain of your From Email domain and must have a CNAME record that points to pm.mtasv.net. For more information about this field, please read our support page.
	ReturnPathDomain string `json:",omitempty"`
}

type UpdateMessageStreamInput

type UpdateMessageStreamInput struct {
	Name                                string                                           `json:"Name,omitempty"`
	Description                         string                                           `json:"Description,omitempty"`
	SubscriptionManagementConfiguration MessageStreamSubscriptionManagementConfiguration `json:"SubscriptionManagementConfiguration,omitempty"`
}

Jump to

Keyboard shortcuts

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