sendgrid 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +16 -0
- data/VERSION +1 -1
- data/lib/sendgrid.rb +26 -2
- metadata +2 -2
data/README.textile
CHANGED
@@ -100,6 +100,22 @@ Here are a list of supported options for sendgrid_enable and sendgrid_disable:
|
|
100
100
|
|
101
101
|
For further explanation see "SendGrid's wiki page on filters.":http://wiki.sendgrid.com/doku.php?id=filters
|
102
102
|
|
103
|
+
h3. Delivering to multiple recipients
|
104
|
+
|
105
|
+
There is a per-mailer-method setting that can be used to deliver campaigns to multiple recipients at once. You should still set the "recipients" to an address per the normal ActionMailer usage, but it will not be used.
|
106
|
+
|
107
|
+
<pre>
|
108
|
+
sendgrid_recipients ["email1@blah.com", "email2@blah.com", "email2@blah.com", ...]
|
109
|
+
</pre>
|
110
|
+
|
111
|
+
One issue that arises when delivering multiple emails at once is custom content. Luckily, there is also a per-mailer-method setting that can be used to substitute custom content.
|
112
|
+
|
113
|
+
<pre>
|
114
|
+
sendgrid_substitue "<subme>", ["sub text for 1st recipient", "sub text for 2nd recipient", "sub text for 3rd recipient", ...]
|
115
|
+
</pre>
|
116
|
+
|
117
|
+
In this example, if "<subme>" is in the body of your email SendGrid will automatically substitute it for the string corresponding the recipient being delivered to. NOTE: You should ensure that the length of the substitution array is equal to the length of the recipients array.
|
118
|
+
|
103
119
|
h3. TODO
|
104
120
|
|
105
121
|
* Test coverage (I would appreciate help writing tests).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/sendgrid.rb
CHANGED
@@ -18,7 +18,7 @@ module SendGrid
|
|
18
18
|
attr_accessor :default_sg_category, :default_sg_options, :default_subscriptiontrack_text,
|
19
19
|
:default_footer_text, :default_spamcheck_score
|
20
20
|
end
|
21
|
-
attr_accessor :sg_category, :sg_options, :sg_disabled_options, :subscriptiontrack_text, :footer_text, :spamcheck_score
|
21
|
+
attr_accessor :sg_category, :sg_options, :sg_disabled_options, :sg_recipients, :sg_substitutions, :subscriptiontrack_text, :footer_text, :spamcheck_score
|
22
22
|
end
|
23
23
|
base.extend(ClassMethods)
|
24
24
|
end
|
@@ -87,6 +87,20 @@ module SendGrid
|
|
87
87
|
options.each { |option| @sg_disabled_options << option if VALID_OPTIONS.include?(option) }
|
88
88
|
end
|
89
89
|
|
90
|
+
# Call within mailer method to add an array of recipients
|
91
|
+
def sendgrid_recipients(emails)
|
92
|
+
@sg_recipients = Array.new unless @sg_recipients
|
93
|
+
@sg_recipients = emails
|
94
|
+
end
|
95
|
+
|
96
|
+
# Call within mailer method to add an array of substitions
|
97
|
+
# NOTE: you must ensure that the length of the substitions equals the
|
98
|
+
# length of the sendgrid_recipients.
|
99
|
+
def sendgrid_substitute(placeholder, subs)
|
100
|
+
@sg_substitutions = Hash.new unless @sg_substitutions
|
101
|
+
@sg_substitutions[placeholder] = subs
|
102
|
+
end
|
103
|
+
|
90
104
|
# Call within mailer method to override the default value.
|
91
105
|
def sendgrid_subscriptiontrack_text(texts)
|
92
106
|
@subscriptiontrack_text = texts
|
@@ -125,6 +139,16 @@ module SendGrid
|
|
125
139
|
elsif self.class.default_sg_category
|
126
140
|
header_opts[:category] = self.class.default_sg_category
|
127
141
|
end
|
142
|
+
|
143
|
+
# Set multi-recipients
|
144
|
+
if @sg_recipients && !@sg_recipients.empty?
|
145
|
+
header_opts[:to] = @sg_recipients
|
146
|
+
end
|
147
|
+
|
148
|
+
# Set custom substitions
|
149
|
+
if @sg_substitutions && !@sg_substitutions.empty?
|
150
|
+
header_opts[:sub] = @sg_substitutions
|
151
|
+
end
|
128
152
|
|
129
153
|
# Set enables/disables
|
130
154
|
header_opts[:filters] = {} unless header_opts.has_key?(:filters)
|
@@ -140,7 +164,7 @@ module SendGrid
|
|
140
164
|
if !enabled_opts.empty? || (@sg_disabled_options && !@sg_disabled_options.empty?)
|
141
165
|
header_opts[:filters] = filters_hash_from_options(enabled_opts, @sg_disabled_options)
|
142
166
|
end
|
143
|
-
|
167
|
+
|
144
168
|
header_opts.to_json
|
145
169
|
end
|
146
170
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendgrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Blankenship
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|