Skip to content

hjr265/postmark.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postmark.go

Postmark.go is a Go client library for the Postmark API.

Installation

go get github.com/hjr265/postmark.go/postmark

Usage

Send a Single Email

c := postmark.New("YOUR-API-KEY")

resp, err := c.SendEmail(&postmark.EmailRequest{
    From:     "sender@example.com",
    To:       "recipient@example.com",
    Subject:  "Hello",
    TextBody: "Hello from Postmark!",
})

Send Batch Emails

resp, err := c.SendEmailBatch([]*postmark.EmailRequest{
    {
        From:     "sender@example.com",
        To:       "recipient1@example.com",
        Subject:  "Hello",
        TextBody: "Hello from Postmark!",
    },
    {
        From:     "sender@example.com",
        To:       "recipient2@example.com",
        Subject:  "Hello",
        TextBody: "Hello from Postmark!",
    },
})

Send Bulk Email

resp, err := c.SendBulkEmail(&postmark.BulkEmailRequest{
    From:          "sender@example.com",
    Subject:       "Hello {{FirstName}}",
    TextBody:      "Hello {{FirstName}}!",
    MessageStream: "broadcast",
    Messages: []postmark.BulkMessage{
        {
            To:            "recipient1@example.com",
            TemplateModel: map[string]string{"FirstName": "Alice"},
        },
        {
            To:            "recipient2@example.com",
            TemplateModel: map[string]string{"FirstName": "Bob"},
        },
    },
})

Check Bulk Email Status

status, err := c.GetBulkEmailStatus("bulk-request-id")

Custom Host

c := postmark.New("YOUR-API-KEY", postmark.WithHost("custom.api.host"))

Documentation

Contributing

Contributions are welcome.

License

Postmark.go is available under the BSD (3-Clause) License.

About

A Go library for the Postmark API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages