forked from eddiezane/smtpapi-ruby
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathexample.rb
More file actions
81 lines (64 loc) · 2.17 KB
/
example.rb
File metadata and controls
81 lines (64 loc) · 2.17 KB
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
81
require_relative '../lib/smtpapi'
header = Smtpapi::Header.new
## add_to
header.add_to('test1@example.com')
header.add_to('test2@example.com', 'other')
# header.add_to(['test1@example.com', 'test2@example.com'])
## set_tos
# header.set_tos(['you@youremail.com', 'other@otheremail.com'])
# to => ['you@youremail.com', 'other@otheremail.com']
## add_substitution
# sub = {keep: ['secret']}
header.add_substitution('keep', ['secret'])
# sub = {keep: ['secret'], other: ['one', 'two']}
header.add_substitution('other', %w(one two))
## set_substitutions
# header.set_substitutions({'keep' => 'secret'}) # sub = {keep: ['secret']}
## add_unique_arg
header.add_unique_arg('cat', 'dogs')
## set_unique_args
# header.set_unique_args({'cow' => 'chicken'})
# header.set_unique_args({'dad' => 'proud'})
## add_category
# category = ['tactics']
header.add_category('tactics')
# category = ['tactics', 'advanced']
header.add_category('advanced')
## set_categories
# category = ['tactics', 'advanced']
# header.set_categories(['tactics', 'advanced'])
## add_section
header.add_section('-charge-', 'This ship is useless.')
header.add_section('-bomber-', 'Only for sad vikings.')
## set_sections
# header.set_sections({'-charge-' => 'This ship is useless.'})
## add_filter
header.add_filter('footer', 'enable', 1)
header.add_filter('footer', 'text/html', '<strong>boo</strong>')
## set_filters
# filter = {
# 'footer' => {
# 'setting' => {
# 'enable' => 1,
# "text/plain" => 'You can haz footers!'
# }
# }
# }
# header.set_filters(filter)
## set_send_at
lt = Time.local(2014, 8, 29, 17, 56, 35)
header.set_send_at(lt)
## set_send_each_at
# lt1 = Time.local(2014, 8, 29, 17, 56, 35)
# lt2 = Time.local(2013, 12, 31, 0, 0, 0)
# lt3 = Time.local(2015, 9, 1, 4, 5, 6)
# header.set_send_each_at([lt1, lt2, lt3])
## asm_group_id
# This is to specify an ASM Group for the message.
# See: https://sendgrid.com/docs/User_Guide/advanced_suppression_manager.html
header.set_asm_group(2)
## set_ip_pool
# Using IP Pools with the SMTP API Header
# See: https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_pools.html)
header.set_ip_pool('test_pool')
print header.to_json