-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
38 lines (33 loc) · 846 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"net/http"
"github.com/mattevans/postmark-go"
)
func main() {
// Init client with round tripper adding auth fields.
client := postmark.NewClient(
postmark.WithClient(&http.Client{
Transport: &postmark.AuthTransport{Token: "SERVER_API_TOKEN"},
}),
)
// Build the email.
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,
Metadata: map[string]string{
"client-id": "123456",
"client-ip": "127.0.0.1",
},
}
// Send it!
_, response, err := client.Email.Send(emailReq)
if err != nil {
fmt.Printf("ERR: \n%v\n%v\n", response, err)
}
}