postal

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: MIT Imports: 12 Imported by: 0

README

Postal-Go

This is a client library for Postal.

Uses the Send a raw RFC2882 message api.

Docs

See the docs at Godoc.

Documentation

Index

Constants

View Source
const (
	HdrContentType             = "Content-Type"
	HdrContentTransferEncoding = "Content-Transfer-Encoding"
	HdrContentDisposition      = "Content-Disposition"
	ContentTypeOctetStream     = "application/octet-stream"
	HdrContentID               = "Content-ID"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiClient

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

func (*ApiClient) SendMessage

func (a *ApiClient) SendMessage(msg Message) (Response, error)

SendMessage sends the given message to postal.

type Client

type Client interface {
	SendMessage(Message) (Response, error)
}

Client is the client for postal.

func NewAPIClient

func NewAPIClient(url, token string, httpClient *http.Client) (Client, error)

NewAPIClient returns a postal client which uses the API.

type Message

type Message struct {
	To        []string
	From      string
	Sender    string
	Subject   string
	ReplyTo   []string
	Cc        []string
	Bcc       []string
	PlainBody string
	HTMLBody  string
	Headers   textproto.MIMEHeader
	// contains filtered or unexported fields
}

Message is the email which needs to be sent.

func (*Message) Attach

func (m *Message) Attach(r io.Reader, filename string, contentType string, headers textproto.MIMEHeader) error

Attach creates an attachment in the message. `headers` is optional. If given, it will add the headers to the attachment.

func (*Message) AttachFile

func (m *Message) AttachFile(filename string) error

AttachFile attaches given file to the message. This is a wrapper over Attach function.

type Response

type Response struct {
	MessageID string                     `json:"message_id"`
	Messages  map[string]ResponseMessage `json:"messages"`
}

type ResponseMessage

type ResponseMessage struct {
	ID    int64  `json:"id"`
	Token string `json:"token"`
}

Jump to

Keyboard shortcuts

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