postmark-rails 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2a5b9a0937f1bda26743204ebeef53656210e5b
4
- data.tar.gz: d56a163059b6b033a376ac762adcbe66601bd059
3
+ metadata.gz: 11103f47e603b5ae549757fb861bff414067ca90
4
+ data.tar.gz: 862e1cb8268be1498a138440ba5abb63ea4a8045
5
5
  SHA512:
6
- metadata.gz: 1bba6d10683068621f0468af583b5a93ca0739056cbab26730fd3dbc9765f02225ebdc3509b72e6f09cefbb1d46d24d7da143e71cf877d0e33a455222247e37d
7
- data.tar.gz: eac0b6e74a69acaa17e5c970ea45a00b1df47d5bd46a0ea06c20005e5fb7777cb4941a01db5268c3186fbbfa23a955a764fba546506664d6a309cff56393a9b3
6
+ metadata.gz: eaf79340d2482125dd51cf6b380c5bc33aac14bb2718a46735bea798df0ef185a68ee94509129a011369014e4978588f3d2f0c39ba71aaa4162668b4dc745f20
7
+ data.tar.gz: b260ee5d8aa82bcbd7492fb91a812faac8365dd18d0ae95ce4a2e6714ad9750964e7dba32c1a167b030b5f38a9460336f3cb06246dbfd739d268bf3611a6ff3c
@@ -1,5 +1,10 @@
1
1
  = Changelog
2
2
 
3
+ == 0.16.0
4
+
5
+ * Update the postmark gem dependency to 1.11.x.
6
+ * Added a section on error handling to the README.
7
+
3
8
  == 0.15.0
4
9
 
5
10
  * Update the postmark gem dependency to 1.10.x.
data/Gemfile CHANGED
@@ -3,6 +3,6 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  group :test do
6
- gem 'rspec', '~> 2.14.0'
7
- gem 'mime-types', '~> 1.25.1'
6
+ gem 'rspec', '~> 3.7'
7
+ gem 'mime-types', '~> 3.1'
8
8
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Petyo Ivanov
1
+ Copyright (c) 2009 Wildbit LLC.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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 this to your Gemfile: (change version numbers if needed)
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
- Don’t forget to run `bundle install` command every time you change something in the Gemfile.
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
- Add this to your config/application.rb:
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 => "your-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 [all options](https://github.com/wildbit/postmark-gem#communicating-with-the-api) supported by `Postmark::ApiClient`.
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—2013 Wildbit LLC. See LICENSE for details.
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.10.0', :path => ENV['POSTMARK_GEM_PATH']
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', '~> 2.14.0'
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.10.0', :path => ENV['POSTMARK_GEM_PATH']
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', '~> 2.14.0'
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.10.0', path: ENV['POSTMARK_GEM_PATH']
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', '~> 2.14.0'
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.10.0', path: ENV['POSTMARK_GEM_PATH']
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', '~> 2.14.0'
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.10.0', path: ENV['POSTMARK_GEM_PATH']
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', '~> 2.14.0'
10
+ gem 'rspec', '~> 3.7'
11
11
  gem 'mime-types', '~> 1.25.1'
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module PostmarkRails
2
- VERSION = '0.15.0'
2
+ VERSION = '0.16.0'
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.rdoc_options = ["--charset=UTF-8"]
18
18
 
19
19
  s.add_dependency('actionmailer', ">= 3.0.0")
20
- s.add_dependency('postmark', "~> 1.10.0")
20
+ s.add_dependency('postmark', "~> 1.11.0")
21
21
 
22
22
  s.add_development_dependency("rake")
23
23
 
@@ -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 be_true
39
- expect(message.to_postmark_hash['TrackOpens']).to be_true
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.15.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: 2016-11-28 00:00:00.000000000 Z
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.10.0
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.10.0
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.4.5.1
117
+ rubygems_version: 2.6.14
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Postmark adapter for ActionMailer