/
example.go
80 lines (68 loc) · 2.18 KB
/
example.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"fmt"
"github.com/sendgrid/smtpapi-go"
)
func main() {
header := smtpapi.NewSMTPAPIHeader()
// Recipients
header.AddTo("[email protected]")
// or
//tos := []string{"[email protected]", "[email protected]"}
//header.AddTos(tos)
// or
//header.SetTos(tos)
//[Substitutions](http://sendgrid.com/docs/API_Reference/SMTP_API/substitution_tags.html)
header.AddSubstitution("key", "value")
// or
//values := []string{"value1", "value2"}
//header.AddSubstitutions("key", values)
// or
//sub := make(map[string][]string)
//sub["key"] = values
//header.SetSubstitutions(sub)
//[Section](http://sendgrid.com/docs/API_Reference/SMTP_API/section_tags.html)
header.AddSection("section", "value")
// or
//sections := make(map[string]string)
//sections["section"] = "value"
//header.SetSections(sections)
//[Category](http://sendgrid.com/docs/Delivery_Metrics/categories.html)
header.AddCategory("category")
// or
//categories := []string{"setCategories"}
//header.AddCategories(categories)
// or
//header.SetCategories(categories)
//[Unique Arguments](http://sendgrid.com/docs/API_Reference/SMTP_API/unique_arguments.html)
header.AddUniqueArg("key", "value")
// or
//args := make(map[string]string)
//args["key"] = "value"
//header.SetUniqueArgs(args)
//[Filters](http://sendgrid.com/docs/API_Reference/SMTP_API/apps.html)
header.AddFilter("filter", "setting", "value")
// or
/*
filter := &Filter{
Settings: make(map[string]string),
}
filter.Settings["enable"] = "1"
filter.Settings["text/plain"] = "You can haz footers!"
header.SetFilter("footer", filter)
*/
//[Send At](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)
header.SetSendAt(1428611024)
// or
//sendEachAt := []int64{1428611024, 1428611025}
//header.SetSendEachAt(sendEachAt)
// or
//header.AddSendEachAt(1428611024)
//header.AddSendEachAt(1428611025)
//[ASM Group ID](https://sendgrid.com/docs/User_Guide/advanced_suppression_manager.html)
asmGroupID := 1
header.SetASMGroupID(asmGroupID)
// [IP Pools](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_pools.html)
header.SetIpPool("testPool")
fmt.Println(header.JSONString())
}