-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
37 lines (28 loc) · 955 Bytes
/
example_test.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
package postmark_test
import (
"fmt"
"log"
"github.com/dkfbasel/postmark"
)
func ExampleService() {
// initialize the service
mailer, err := postmark.New(postmark.DefaultHost, postmark.TestApiKey,
postmark.Address("DKFBasel", "info@dkfbasel.ch"))
if err != nil {
log.Fatalf("could not initialize postmark service: %+v\n", err)
}
// compose a new message, use postmark.Emails for multiple email addresses
// or postmark.Addresses for multiple addresses
message := postmark.Message{
To: postmark.Emails("someone@dkfbasel.ch", "someone-else@dkfbasel.ch"),
Subject: "This is a subject",
TextBody: "MESSAGE-BODY-AS-TEXT",
}
// send the message through the postmark service
response, err := mailer.Send(&message)
if err != nil {
log.Fatalf("could not send the message: %+v\n", err)
}
fmt.Printf("%s: %s\n", response.Message, response.To)
// Output: Test job accepted: someone@dkfbasel.ch, someone-else@dkfbasel.ch
}