mandrill_mailer 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +8 -2
- data/lib/mandrill_mailer/template_mailer.rb +23 -2
- data/lib/mandrill_mailer/version.rb +1 -1
- data/mandrill_mailer.gemspec +1 -0
- data/spec/template_mailer_spec.rb +10 -1
- metadata +53 -40
- checksums.yaml +0 -15
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -114,6 +114,12 @@ Creating a new Mandrill Mailer is similar to a normal Rails mailer:
|
|
114
114
|
* `filename:` The name of the file
|
115
115
|
* `mimetype:` This is the mimetype of the file. Ex. png = image/png, pdf = application/pdf, txt = text/plain etc
|
116
116
|
|
117
|
+
* `:async` - Whether or not this message should be sent asynchronously
|
118
|
+
|
119
|
+
* `:ip_pool` - The name of the dedicated ip pool that should be used to send the message
|
120
|
+
|
121
|
+
* `:send_at` - When this message should be sent
|
122
|
+
|
117
123
|
## Sending an email
|
118
124
|
|
119
125
|
You can send the email by using the familiar syntax:
|
@@ -175,7 +181,7 @@ def update_email_on_newsletter_subscription(user)
|
|
175
181
|
Delayed::Job.enqueue( UpdateEmailJob.new(user_id: user.id) )
|
176
182
|
end
|
177
183
|
```
|
178
|
-
The job looks like (Don't send full objects into jobs, send ids and requery inside the job. This prevents Delayed Job from having to serialize and deserialize whole ActiveRecord
|
184
|
+
The job looks like (Don't send full objects into jobs, send ids and requery inside the job. This prevents Delayed Job from having to serialize and deserialize whole ActiveRecord Objects and this way, your data is current when the job runs):
|
179
185
|
|
180
186
|
```ruby
|
181
187
|
class UpdateEmailJob < Struct.new(:user_id)
|
@@ -184,4 +190,4 @@ class UpdateEmailJob < Struct.new(:user_id)
|
|
184
190
|
HallpassMailer.hallpass_expired(user).deliver
|
185
191
|
end
|
186
192
|
end
|
187
|
-
```
|
193
|
+
```
|
@@ -168,6 +168,15 @@ module MandrillMailer
|
|
168
168
|
# Public: Other information on the message to send
|
169
169
|
attr_accessor :message
|
170
170
|
|
171
|
+
# Public: Enable background sending mode
|
172
|
+
attr_accessor :async
|
173
|
+
|
174
|
+
# Public: Name of the dedicated IP pool that should be used to send the message
|
175
|
+
attr_accessor :ip_pool
|
176
|
+
|
177
|
+
# Public: When message should be sent
|
178
|
+
attr_accessor :send_at
|
179
|
+
|
171
180
|
# Public: Triggers the stored Mandril params to be sent to the Mandrill api
|
172
181
|
#
|
173
182
|
# text - The String to be duplicated.
|
@@ -181,7 +190,7 @@ module MandrillMailer
|
|
181
190
|
# Returns the duplicated String.
|
182
191
|
def deliver
|
183
192
|
mandrill = Mandrill::API.new(api_key)
|
184
|
-
mandrill.messages.send_template(template_name, template_content, message)
|
193
|
+
mandrill.messages.send_template(template_name, template_content, message, async, ip_pool, send_at)
|
185
194
|
end
|
186
195
|
|
187
196
|
# Public: Build the hash needed to send to the mandrill api
|
@@ -198,6 +207,9 @@ module MandrillMailer
|
|
198
207
|
# :google_analytics_campaign - Google analytics campaign
|
199
208
|
# :inline_css - whether or not to automatically inline all CSS styles provided in the message HTML
|
200
209
|
# :important - whether or not this message is important
|
210
|
+
# :async - whether or not this message should be sent asynchronously
|
211
|
+
# :ip_pool - name of the dedicated IP pool that should be used to send the message
|
212
|
+
# :send_at - when this message should be sent
|
201
213
|
#
|
202
214
|
# Examples
|
203
215
|
#
|
@@ -227,6 +239,12 @@ module MandrillMailer
|
|
227
239
|
# Set the template content
|
228
240
|
self.template_content = mandrill_args(args.delete(:template_content))
|
229
241
|
|
242
|
+
self.async = args.delete(:async)
|
243
|
+
self.ip_pool = args.delete(:ip_pool)
|
244
|
+
if args.has_key?(:send_at)
|
245
|
+
self.send_at = args.delete(:send_at).getutc.strftime('%Y-%m-%d %H:%M:%S')
|
246
|
+
end
|
247
|
+
|
230
248
|
# Construct message hash
|
231
249
|
self.message = {
|
232
250
|
"subject" => args[:subject],
|
@@ -261,7 +279,10 @@ module MandrillMailer
|
|
261
279
|
"key" => api_key,
|
262
280
|
"template_name" => template_name,
|
263
281
|
"template_content" => template_content,
|
264
|
-
"message" => message
|
282
|
+
"message" => message,
|
283
|
+
"async" => async,
|
284
|
+
"ip_pool" => ip_pool,
|
285
|
+
"send_at" => send_at
|
265
286
|
}
|
266
287
|
end
|
267
288
|
|
data/mandrill_mailer.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "https://github.com/renz45/mandrill_mailer"
|
12
12
|
s.summary = %q{Transactional Mailer for Mandrill}
|
13
13
|
s.description = %q{Transactional Mailer for Mandrill}
|
14
|
+
s.license = 'MIT'
|
14
15
|
|
15
16
|
s.files = `git ls-files`.split("\n")
|
16
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -129,6 +129,7 @@ describe MandrillMailer::TemplateMailer do
|
|
129
129
|
let(:attachment_file) { File.read(File.expand_path('spec/support/test_image.png')) }
|
130
130
|
let(:attachment_filename) { 'test_image.png' }
|
131
131
|
let(:attachment_mimetype) { 'image/png' }
|
132
|
+
let(:send_at) { Time.utc(2020, 1, 1, 8, 0) }
|
132
133
|
|
133
134
|
let(:args) do
|
134
135
|
{
|
@@ -150,7 +151,8 @@ describe MandrillMailer::TemplateMailer do
|
|
150
151
|
google_analytics_campaign: '1237423474',
|
151
152
|
attachments: [{file: attachment_file, filename: attachment_filename, mimetype: attachment_mimetype}],
|
152
153
|
inline_css: true,
|
153
|
-
important: true
|
154
|
+
important: true,
|
155
|
+
send_at: send_at
|
154
156
|
}
|
155
157
|
end
|
156
158
|
|
@@ -202,8 +204,15 @@ describe MandrillMailer::TemplateMailer do
|
|
202
204
|
"template_name" => subject.template_name,
|
203
205
|
"template_content" => subject.template_content,
|
204
206
|
"message" => subject.message,
|
207
|
+
"async" => subject.async,
|
208
|
+
"ip_pool" => subject.ip_pool,
|
209
|
+
"send_at" => subject.send_at
|
205
210
|
})
|
206
211
|
end
|
212
|
+
|
213
|
+
it 'should set send_at option' do
|
214
|
+
subject.send_at.should eq('2020-01-01 08:00:00')
|
215
|
+
end
|
207
216
|
end
|
208
217
|
|
209
218
|
describe 'url helpers in mailer' do
|
metadata
CHANGED
@@ -1,85 +1,96 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mandrill_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Adam Rensel
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activesupport
|
15
|
-
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- -
|
18
|
+
- - '>='
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '0'
|
20
|
-
|
21
|
-
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :runtime
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: actionpack
|
29
|
-
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
33
|
requirements:
|
31
|
-
- -
|
34
|
+
- - '>='
|
32
35
|
- !ruby/object:Gem::Version
|
33
36
|
version: '0'
|
34
|
-
|
35
|
-
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
37
39
|
requirements:
|
38
|
-
- -
|
40
|
+
- - '>='
|
39
41
|
- !ruby/object:Gem::Version
|
40
42
|
version: '0'
|
43
|
+
none: false
|
44
|
+
prerelease: false
|
45
|
+
type: :runtime
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: mandrill-api
|
43
|
-
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
49
|
requirements:
|
45
50
|
- - ~>
|
46
51
|
- !ruby/object:Gem::Version
|
47
52
|
version: 1.0.9
|
48
|
-
|
49
|
-
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
51
55
|
requirements:
|
52
56
|
- - ~>
|
53
57
|
- !ruby/object:Gem::Version
|
54
58
|
version: 1.0.9
|
59
|
+
none: false
|
60
|
+
prerelease: false
|
61
|
+
type: :runtime
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: pry
|
57
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
65
|
requirements:
|
59
|
-
- -
|
66
|
+
- - '>='
|
60
67
|
- !ruby/object:Gem::Version
|
61
68
|
version: '0'
|
62
|
-
|
63
|
-
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- -
|
72
|
+
- - '>='
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '0'
|
75
|
+
none: false
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rspec
|
71
|
-
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
81
|
requirements:
|
73
|
-
- -
|
82
|
+
- - '>='
|
74
83
|
- !ruby/object:Gem::Version
|
75
84
|
version: '0'
|
76
|
-
|
77
|
-
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
79
87
|
requirements:
|
80
|
-
- -
|
88
|
+
- - '>='
|
81
89
|
- !ruby/object:Gem::Version
|
82
90
|
version: '0'
|
91
|
+
none: false
|
92
|
+
prerelease: false
|
93
|
+
type: :development
|
83
94
|
description: Transactional Mailer for Mandrill
|
84
95
|
email:
|
85
96
|
- adamrensel@codeschool.com
|
@@ -102,27 +113,29 @@ files:
|
|
102
113
|
- spec/support/test_image.png
|
103
114
|
- spec/template_mailer_spec.rb
|
104
115
|
homepage: https://github.com/renz45/mandrill_mailer
|
105
|
-
licenses:
|
106
|
-
|
107
|
-
post_install_message:
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
post_install_message:
|
108
119
|
rdoc_options: []
|
109
120
|
require_paths:
|
110
121
|
- lib
|
111
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
123
|
requirements:
|
113
|
-
- -
|
124
|
+
- - '>='
|
114
125
|
- !ruby/object:Gem::Version
|
115
126
|
version: '0'
|
127
|
+
none: false
|
116
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
129
|
requirements:
|
118
|
-
- -
|
130
|
+
- - '>='
|
119
131
|
- !ruby/object:Gem::Version
|
120
132
|
version: '0'
|
133
|
+
none: false
|
121
134
|
requirements: []
|
122
|
-
rubyforge_project:
|
123
|
-
rubygems_version:
|
124
|
-
signing_key:
|
125
|
-
specification_version:
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 1.8.24
|
137
|
+
signing_key:
|
138
|
+
specification_version: 3
|
126
139
|
summary: Transactional Mailer for Mandrill
|
127
140
|
test_files:
|
128
141
|
- spec/fake_rails/fake_rails.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ZjU3N2RkOTU1MzJlYWYzYjk0ZDIwYjQ3OGMyODE3OGQ2YjY3ZTM0MQ==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZTc2YjBkMjU5MTQ4MmRiZDI2NDE1YzlmNTQ1ZTY4MTUzYTdmOWU0MQ==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NTVmZjE0NTBhNzU5NGJiN2YyOGRiM2RkNzRlOWIyOTA2ZTE0MGQzZWMyYzA4
|
10
|
-
ZmMyNWUzYTZhN2ZhNWE4YmZjMGNjOGMyMzQ4ZjM3ZjNhNDM5Y2ZkNjk4ZTRi
|
11
|
-
Nzc2ZGQ3NDllZTEyMGY3MjEwOGZiNmM1Y2IzNTYzNzIyOWIxNjE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzYwMTJkZWI2MGUyMzY2ZDdlYjBkM2I4NjA1NzQzOTVkZDYzMmU3NzQwMzhi
|
14
|
-
ZDhkM2ZiOGZmNmY3ZWIwZmI0OTY2YjgyMmNmYmE5NDk4NzU3OGFiNDdkY2Yy
|
15
|
-
ZjExZTE5YThmZjc2ZDJiN2EwYTM1MzkxMzg3MTZhNjdhNWE4OTM=
|