postmark-rails 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +5 -0
- data/Gemfile +2 -2
- data/LICENSE +1 -1
- data/README.md +105 -8
- data/gemfiles/Gemfile.actionmailer-3.0.x +2 -2
- data/gemfiles/Gemfile.actionmailer-3.2.x +2 -2
- data/gemfiles/Gemfile.actionmailer-4.0.x +2 -2
- data/gemfiles/Gemfile.actionmailer-4.1.x +2 -2
- data/gemfiles/Gemfile.actionmailer-4.2.x +2 -2
- data/lib/postmark-rails/version.rb +1 -1
- data/postmark-rails.gemspec +1 -1
- data/spec/postmark-rails_spec.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11103f47e603b5ae549757fb861bff414067ca90
|
4
|
+
data.tar.gz: 862e1cb8268be1498a138440ba5abb63ea4a8045
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaf79340d2482125dd51cf6b380c5bc33aac14bb2718a46735bea798df0ef185a68ee94509129a011369014e4978588f3d2f0c39ba71aaa4162668b4dc745f20
|
7
|
+
data.tar.gz: b260ee5d8aa82bcbd7492fb91a812faac8365dd18d0ae95ce4a2e6714ad9750964e7dba32c1a167b030b5f38a9460336f3cb06246dbfd739d268bf3611a6ff3c
|
data/CHANGELOG.rdoc
CHANGED
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -14,24 +14,26 @@ For Rails 2.3 please take a look at [version 0.4](https://github.com/wildbit/pos
|
|
14
14
|
|
15
15
|
## Configuring your Rails application
|
16
16
|
|
17
|
-
Add
|
17
|
+
Add `postmark-rails` to your Gemfile (change version numbers if needed) and run `bundle install`.
|
18
18
|
|
19
19
|
``` ruby
|
20
20
|
gem 'postmark-rails', '~> 0.15.0'
|
21
21
|
```
|
22
22
|
|
23
|
-
|
23
|
+
Save your Postmark API token to [config/secrets.yml](http://guides.rubyonrails.org/4_1_release_notes.html#config-secrets-yml).
|
24
24
|
|
25
|
-
|
25
|
+
``` yaml
|
26
|
+
postmark_api_token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
27
|
+
```
|
28
|
+
|
29
|
+
Set Postmark as your preferred mail delivery method via `config/application.rb`:
|
26
30
|
|
27
31
|
``` ruby
|
28
32
|
config.action_mailer.delivery_method = :postmark
|
29
|
-
config.action_mailer.postmark_settings = { :api_token =>
|
33
|
+
config.action_mailer.postmark_settings = { :api_token => Rails.application.secrets.postmark_api_token }
|
30
34
|
```
|
31
35
|
|
32
|
-
The `postmark_settings` hash can contain [
|
33
|
-
|
34
|
-
For the API details, refer to the [developer documentation](http://developer.postmarkapp.com).
|
36
|
+
**Note**: The `postmark_settings` hash can contain [any options](https://github.com/wildbit/postmark-gem#communicating-with-the-api) supported by `Postmark::ApiClient`.
|
35
37
|
|
36
38
|
## Tracking opens and tagging your deliveries
|
37
39
|
|
@@ -102,6 +104,101 @@ messages.all?(&:delivered)
|
|
102
104
|
# => true
|
103
105
|
```
|
104
106
|
|
107
|
+
## Error handling
|
108
|
+
|
109
|
+
The gem respects the `ActionMailer::Base.raise_delivery_errors` setting and will surpress any exceptions
|
110
|
+
if it’s set to `false`. When delivery errors are enabled, the gem can raise any one of the exceptions
|
111
|
+
listed in the [postmark](https://github.com/wildbit/postmark-gem#error-handling) gem docs.
|
112
|
+
|
113
|
+
|
114
|
+
### ActionMailer 5
|
115
|
+
|
116
|
+
For ActionMailer 5 and above, use `ActionMailer::Base.rescue_from` to define handlers for
|
117
|
+
each error you care about.
|
118
|
+
|
119
|
+
#### Example
|
120
|
+
|
121
|
+
``` ruby
|
122
|
+
class ApplicationMailer < ActionMailer::Base
|
123
|
+
default from: 'user@example.org'
|
124
|
+
layout 'mailer'
|
125
|
+
|
126
|
+
rescue_from Postmark::InactiveRecipientError, with: :reactivate_and_retry
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def postmark_client
|
131
|
+
::Postmark::ApiClient.new(ActionMailer::Base.postmark_settings[:api_token],
|
132
|
+
ActionMailer::Base.postmark_settings.except(:api_token))
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
# This is just an example. Sometimes you might not want to reactivate
|
137
|
+
# an address that hard bounced.
|
138
|
+
# Warning: Having too many bounces can affect your delivery reputation
|
139
|
+
# with email providers
|
140
|
+
def reactivate_and_retry(error)
|
141
|
+
Rails.logger.info("Error when sending #{message} to #{error.recipients.join(', ')}")
|
142
|
+
Rails.logger.info(error)
|
143
|
+
|
144
|
+
error.recipients.each do |recipient|
|
145
|
+
bounce = postmark_client.bounces(emailFilter: recipient).first
|
146
|
+
next unless bounce
|
147
|
+
postmark_client.activate_bounce(bounce[:id])
|
148
|
+
end
|
149
|
+
|
150
|
+
# Try again immediately
|
151
|
+
message.deliver
|
152
|
+
end
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
### ActionMailer 4 and below
|
157
|
+
|
158
|
+
Wrap any calls to `#deliver_now` in error handlers like the one described
|
159
|
+
in the [postmark](https://github.com/wildbit/postmark-gem#error-handling) gem
|
160
|
+
docs.
|
161
|
+
|
162
|
+
Rails 4.2 introduces `#deliver_later` but doesn’t support `rescue_from` for
|
163
|
+
mailer classes. Instead, use the following monkey patch for
|
164
|
+
`ActionMailer::DeliveryJob`.
|
165
|
+
|
166
|
+
``` ruby
|
167
|
+
# app/mailers/application_mailer.rb
|
168
|
+
|
169
|
+
class ApplicationMailer < ActionMailer::Base
|
170
|
+
default from: 'user@example.org'
|
171
|
+
end
|
172
|
+
|
173
|
+
class ActionMailer::DeliveryJob
|
174
|
+
rescue_from Postmark::InactiveRecipientError, with: :reactivate_and_retry
|
175
|
+
|
176
|
+
def postmark_client
|
177
|
+
::Postmark::ApiClient.new(ActionMailer::Base.postmark_settings[:api_token],
|
178
|
+
ActionMailer::Base.postmark_settings.except(:api_token))
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
# This is just an example. Sometimes you might not want to reactivate
|
183
|
+
# an address that hard bounced.
|
184
|
+
# Warning: Having too many bounces can affect your delivery reputation
|
185
|
+
# with email providers
|
186
|
+
def reactivate_and_retry(error)
|
187
|
+
Rails.logger.info("Error when sending a message to #{error.recipients.join(', ')}")
|
188
|
+
Rails.logger.info(error)
|
189
|
+
|
190
|
+
error.recipients.each do |recipient|
|
191
|
+
bounce = postmark_client.bounces(emailFilter: recipient).first
|
192
|
+
next unless bounce
|
193
|
+
postmark_client.activate_bounce(bounce[:id])
|
194
|
+
end
|
195
|
+
|
196
|
+
# Try again immediately
|
197
|
+
perform(*arguments)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
105
202
|
## Additional information
|
106
203
|
|
107
204
|
Looking for the advanced usage examples? Check out [the documentation](https://github.com/wildbit/postmark-gem/blob/master/README.md) for the `postmark` gem. The `postmark-rails` gem is built on top of it, so you can benefit from all its features.
|
@@ -133,4 +230,4 @@ Looking for the advanced usage examples? Check out [the documentation](https://g
|
|
133
230
|
|
134
231
|
## Copyright
|
135
232
|
|
136
|
-
Copyright © 2010—
|
233
|
+
Copyright © 2010—2018 Wildbit LLC. See LICENSE for details.
|
@@ -4,11 +4,11 @@ gemspec :path => '../'
|
|
4
4
|
|
5
5
|
gem 'json', '< 2.0.0'
|
6
6
|
gem 'rake', '< 11.0.0'
|
7
|
-
gem 'postmark', '~> 1.
|
7
|
+
gem 'postmark', '~> 1.11.0', :path => ENV['POSTMARK_GEM_PATH']
|
8
8
|
gem 'actionmailer', '~> 3.0.0'
|
9
9
|
gem 'rack-cache', '~> 1.2.0'
|
10
10
|
|
11
11
|
group :test do
|
12
|
-
gem 'rspec', '~>
|
12
|
+
gem 'rspec', '~> 3.7'
|
13
13
|
gem 'mime-types', '~> 1.25.1'
|
14
14
|
end
|
@@ -4,12 +4,12 @@ gemspec :path => '../'
|
|
4
4
|
|
5
5
|
gem 'json', '< 2.0.0'
|
6
6
|
gem 'rake', '< 11.0.0'
|
7
|
-
gem 'postmark', '~> 1.
|
7
|
+
gem 'postmark', '~> 1.11.0', :path => ENV['POSTMARK_GEM_PATH']
|
8
8
|
gem 'actionmailer', :github => 'rails', :branch => '3-2-stable'
|
9
9
|
gem 'i18n', '~> 0.6.0'
|
10
10
|
gem 'rack-cache', '~> 1.2.0'
|
11
11
|
|
12
12
|
group :test do
|
13
|
-
gem 'rspec', '~>
|
13
|
+
gem 'rspec', '~> 3.7'
|
14
14
|
gem 'mime-types', '~> 1.25.1'
|
15
15
|
end
|
@@ -3,10 +3,10 @@ source "https://rubygems.org"
|
|
3
3
|
gemspec :path => '../'
|
4
4
|
|
5
5
|
gem 'json', '< 2.0.0'
|
6
|
-
gem 'postmark', '~> 1.
|
6
|
+
gem 'postmark', '~> 1.11.0', path: ENV['POSTMARK_GEM_PATH']
|
7
7
|
gem 'actionmailer', '~> 4.0.0'
|
8
8
|
|
9
9
|
group :test do
|
10
|
-
gem 'rspec', '~>
|
10
|
+
gem 'rspec', '~> 3.7'
|
11
11
|
gem 'mime-types', '~> 1.25.1'
|
12
12
|
end
|
@@ -3,10 +3,10 @@ source "https://rubygems.org"
|
|
3
3
|
gemspec :path => '../'
|
4
4
|
|
5
5
|
gem 'json', '< 2.0.0'
|
6
|
-
gem 'postmark', '~> 1.
|
6
|
+
gem 'postmark', '~> 1.11.0', path: ENV['POSTMARK_GEM_PATH']
|
7
7
|
gem 'actionmailer', '~> 4.1.0'
|
8
8
|
|
9
9
|
group :test do
|
10
|
-
gem 'rspec', '~>
|
10
|
+
gem 'rspec', '~> 3.7'
|
11
11
|
gem 'mime-types', '~> 1.25.1'
|
12
12
|
end
|
@@ -3,10 +3,10 @@ source "https://rubygems.org"
|
|
3
3
|
gemspec :path => '../'
|
4
4
|
|
5
5
|
gem 'json', '< 2.0.0'
|
6
|
-
gem 'postmark', '~> 1.
|
6
|
+
gem 'postmark', '~> 1.11.0', path: ENV['POSTMARK_GEM_PATH']
|
7
7
|
gem 'actionmailer', '~> 4.2.0'
|
8
8
|
|
9
9
|
group :test do
|
10
|
-
gem 'rspec', '~>
|
10
|
+
gem 'rspec', '~> 3.7'
|
11
11
|
gem 'mime-types', '~> 1.25.1'
|
12
12
|
end
|
data/postmark-rails.gemspec
CHANGED
data/spec/postmark-rails_spec.rb
CHANGED
@@ -35,8 +35,8 @@ describe "PostmarkRails3" do
|
|
35
35
|
it "allows to enable open tracking" do
|
36
36
|
expect(Postmark::ApiClient).to receive(:new) { api_client }
|
37
37
|
expect(api_client).to receive(:deliver_message) do |message|
|
38
|
-
expect(message.track_opens).to
|
39
|
-
expect(message.to_postmark_hash['TrackOpens']).to
|
38
|
+
expect(message.track_opens).to be_truthy
|
39
|
+
expect(message.to_postmark_hash['TrackOpens']).to be true
|
40
40
|
end
|
41
41
|
deliver(TestMailer.tracked_message)
|
42
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postmark-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petyo Ivanov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-03-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionmailer
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 1.
|
35
|
+
version: 1.11.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.
|
42
|
+
version: 1.11.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rake
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.6.14
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Postmark adapter for ActionMailer
|