-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (30 loc) · 664 Bytes
/
Copy pathmain.go
File metadata and controls
39 lines (30 loc) · 664 Bytes
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
39
package main
import (
"fmt"
"io/ioutil"
"github.com/shindakun/atlg/go-api-03/client"
"github.com/shindakun/envy"
)
const apiurl = "https://api.mailgun.net/v3/youremaildomain.com"
func main() {
mgKey, err := envy.Get("MGKEY")
if err != nil {
panic(err)
}
mgc := client.NewMgClient(apiurl, mgKey)
req, err := mgc.FormatEmailRequest("<Name> some@email.domain",
"other@email.domain", "Test email", "This is a test email!")
if err != nil {
panic(err)
}
res, err := mgc.Client.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}