Arttii / postmark-go

✉️ Golang bindings for the Postmark API

Home Page:http://developer.postmarkapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postmark-go

GoDoc Build Status license

postmark-go is a Go client library for accessing the Postmark API (http://developer.postmarkapp.com/).

This is an unofficial library that is not affiliated with Postmark. Official libraries are available here.

Installation

go get -u github.com/mattevans/postmark-go

Setup

You'll need to pass an SERVER_API_TOKEN when initializing the client. This token can be found under the 'Credentials' tab of your Postmark server. More info here.

Authentication

auth := &http.Client{
  Transport: &postmark.AuthTransport{Token: "SERVER_API_TOKEN"},
}
client := postmark.NewClient(auth)

Example usage (with Template)

emailReq := &postmark.Email{
  From:       "mail@company.com",
  To:         "jack@sparrow.com",
  TemplateID: 123456,
  TemplateModel: map[string]interface{}{
    "name": "Jack",
    "action_url": "http://click.company.com/welcome",
  },
  Tag:        "onboarding",
  TrackOpens: true,
}

email, response, err := client.Email.Send(emailReq)
if err != nil {
  return err
}

Example usage (with HtmlBody)

emailReq := &postmark.Email{
  From:       "mail@company.com",
  To:         "jack@sparrow.com",
  Subject:    "My Test Email",
  HtmlBody:   "<html><body><strong>Hello</strong> dear Postmark user.</body></html>",
  TextBody:   "Hello dear Postmark user",
  Tag:        "onboarding",
  TrackOpens: true,
}

email, response, err := client.Email.Send(emailReq)
if err != nil {
  return err
}

What's Implemented?

At the moment only a handful of the more common endpoints have been implemented. Open an issue (or PR) if you required something that's missing.

Thanks & Acknowledgements 👌

The packages's architecture is adapted from go-github, created by Will Norris. 🍻

About

✉️ Golang bindings for the Postmark API

http://developer.postmarkapp.com/

License:MIT License


Languages

Language:Go 100.0%