mailgun-ruby 1.1.0 → 1.2.5

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.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.ruby-env.yml.example +1 -1
  4. data/.travis.yml +23 -7
  5. data/Gemfile +2 -0
  6. data/README.md +79 -18
  7. data/{Domains.md → docs/Domains.md} +18 -0
  8. data/{Events.md → docs/Events.md} +0 -0
  9. data/{MessageBuilder.md → docs/MessageBuilder.md} +32 -13
  10. data/{Messages.md → docs/Messages.md} +3 -3
  11. data/{OptInHandler.md → docs/OptInHandler.md} +0 -0
  12. data/{Snippets.md → docs/Snippets.md} +21 -2
  13. data/docs/Suppressions.md +82 -0
  14. data/{Webhooks.md → docs/Webhooks.md} +1 -1
  15. data/docs/railgun/Overview.md +11 -0
  16. data/docs/railgun/Parameters.md +83 -0
  17. data/lib/mailgun/address.rb +48 -0
  18. data/lib/mailgun/client.rb +85 -8
  19. data/lib/mailgun/events/events.rb +40 -12
  20. data/lib/mailgun/exceptions/exceptions.rb +21 -7
  21. data/lib/mailgun/lists/opt_in_handler.rb +0 -1
  22. data/lib/mailgun/messages/batch_message.rb +3 -2
  23. data/lib/mailgun/messages/message_builder.rb +139 -30
  24. data/lib/mailgun/response.rb +7 -0
  25. data/lib/mailgun/suppressions.rb +273 -0
  26. data/lib/mailgun/version.rb +1 -1
  27. data/lib/mailgun/webhooks/webhooks.rb +1 -1
  28. data/lib/mailgun-ruby.rb +2 -0
  29. data/lib/mailgun.rb +1 -0
  30. data/lib/railgun/attachment.rb +56 -0
  31. data/lib/railgun/errors.rb +27 -0
  32. data/lib/railgun/mailer.rb +253 -0
  33. data/lib/railgun/message.rb +18 -0
  34. data/lib/railgun/railtie.rb +10 -0
  35. data/lib/railgun.rb +8 -0
  36. data/mailgun.gemspec +12 -13
  37. data/spec/integration/email_validation_spec.rb +57 -15
  38. data/spec/integration/events_spec.rb +9 -1
  39. data/spec/integration/mailer_spec.rb +67 -0
  40. data/spec/integration/mailgun_spec.rb +51 -1
  41. data/spec/integration/suppressions_spec.rb +142 -0
  42. data/spec/spec_helper.rb +3 -1
  43. data/spec/unit/connection/test_client.rb +16 -0
  44. data/spec/unit/events/events_spec.rb +36 -2
  45. data/spec/unit/mailgun_spec.rb +32 -10
  46. data/spec/unit/messages/batch_message_spec.rb +56 -40
  47. data/spec/unit/messages/message_builder_spec.rb +267 -81
  48. data/spec/unit/messages/sample_data/unknown.type +0 -0
  49. data/spec/unit/railgun/content_type_spec.rb +71 -0
  50. data/spec/unit/railgun/mailer_spec.rb +388 -0
  51. data/vcr_cassettes/email_validation.yml +136 -25
  52. data/vcr_cassettes/events.yml +48 -1
  53. data/vcr_cassettes/exceptions.yml +45 -0
  54. data/vcr_cassettes/mailer_invalid_domain.yml +109 -0
  55. data/vcr_cassettes/message_deliver.yml +149 -0
  56. data/vcr_cassettes/suppressions.yml +727 -0
  57. metadata +65 -40
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+ require 'mailgun'
3
+ require 'railgun'
4
+
5
+ describe 'extract_body' do
6
+
7
+ let(:text_mail_option) {
8
+ {
9
+ from: 'bob@example.com',
10
+ to: 'sally@example.com',
11
+ subject: 'RAILGUN TEST SAMPLE',
12
+ body: text_content,
13
+ content_type: 'text/plain',
14
+ }
15
+ }
16
+ let(:text_content) { '[TEST] Hello, world.' }
17
+
18
+ let(:html_mail_option) {
19
+ {
20
+ from: 'bob@example.com',
21
+ to: 'sally@example.com',
22
+ subject: 'RAILGUN TEST SAMPLE',
23
+ body: html_content,
24
+ content_type: 'text/html',
25
+ }
26
+ }
27
+ let(:html_content) { '<h3> [TEST] </h3> <br/> Hello, world!' }
28
+
29
+ context 'with <Content-Type: text/plain>' do
30
+ let(:sample_mail) { Mail.new(text_mail_option) }
31
+
32
+ it 'should return body text' do
33
+ expect(Railgun.extract_body_text(sample_mail)).to eq(text_content)
34
+ end
35
+
36
+ it 'should not return body html' do
37
+ expect(Railgun.extract_body_html(sample_mail)).to be_nil
38
+ end
39
+ end
40
+
41
+ context 'with <Content-Type: text/html>' do
42
+ let(:sample_mail) { Mail.new(html_mail_option) }
43
+
44
+ it 'should not return body text' do
45
+ expect(Railgun.extract_body_text(sample_mail)).to be_nil
46
+ end
47
+
48
+ it 'should return body html' do
49
+ expect(Railgun.extract_body_html(sample_mail)).to eq(html_content)
50
+ end
51
+ end
52
+
53
+ context 'with <Content-Type: multipart/alternative>' do
54
+ let(:text_mail) { Mail.new(text_mail_option) }
55
+ let(:html_mail) { Mail.new(html_mail_option) }
56
+
57
+ before do
58
+ @sample_mail = Mail::Part.new(content_type: "multipart/alternative")
59
+ @sample_mail.add_part text_mail
60
+ @sample_mail.add_part html_mail
61
+ end
62
+
63
+ it 'should return body text' do
64
+ expect(Railgun.extract_body_text(@sample_mail)).to eq(text_content)
65
+ end
66
+
67
+ it 'should return body html' do
68
+ expect(Railgun.extract_body_html(@sample_mail)).to eq(html_content)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,388 @@
1
+ require 'json'
2
+ require 'logger'
3
+ require 'spec_helper'
4
+ require 'mailgun'
5
+ require 'railgun'
6
+
7
+ ActionMailer::Base.raise_delivery_errors = true
8
+ ActionMailer::Base.delivery_method = :test
9
+ Rails.logger = Logger.new('/dev/null')
10
+ Rails.logger.level = Logger::DEBUG
11
+
12
+ class UnitTestMailer < ActionMailer::Base
13
+ default from: 'unittest@example.org'
14
+
15
+ def plain_message(address, subject, headers)
16
+ headers(headers)
17
+ mail(to: address, subject: subject) do |format|
18
+ format.text { render plain: "Test!" }
19
+ format.html { render html: "<p>Test!</p>".html_safe }
20
+ end
21
+ end
22
+
23
+ def message_with_attachment(address, subject)
24
+ attachments['info.txt'] = {
25
+ :content => File.read('docs/railgun/Overview.md'),
26
+ :mime_type => 'text/plain',
27
+ }
28
+ mail(to: address, subject: subject) do |format|
29
+ format.text { render plain: "Test!" }
30
+ format.html { render html: "<p>Test!</p>".html_safe }
31
+ end
32
+ end
33
+
34
+ def message_with_template(address, subject, template_name)
35
+ mail(to: address, subject: subject, template: template_name) do |format|
36
+ format.text { render plain: "Test!" }
37
+ end
38
+ end
39
+
40
+ def message_with_domain(address, subject, domain)
41
+ mail(to: address, subject: subject, domain: domain) do |format|
42
+ format.text { render plain: "Test!" }
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ describe 'Railgun::Mailer' do
49
+
50
+ it 'has a mailgun_client property which returns a Mailgun::Client' do
51
+ config = {
52
+ api_key: {},
53
+ domain: {}
54
+ }
55
+ @mailer_obj = Railgun::Mailer.new(config)
56
+
57
+ expect(@mailer_obj.mailgun_client).to be_a(Mailgun::Client)
58
+ end
59
+
60
+ context 'when config does not have api_key or domain' do
61
+ it 'raises configuration error' do
62
+ config = {
63
+ api_key: {}
64
+ }
65
+
66
+ expect { Railgun::Mailer.new(config) }.to raise_error(Railgun::ConfigurationError)
67
+ end
68
+ end
69
+
70
+ context 'when fake_message_send is present in config' do
71
+ it 'enables test mode' do
72
+ config = {
73
+ api_key: {},
74
+ domain: {},
75
+ fake_message_send: true
76
+ }
77
+ client_double = double(Mailgun::Client)
78
+ allow(Mailgun::Client).to receive(:new).and_return(client_double)
79
+ expect(client_double).to receive(:enable_test_mode!)
80
+
81
+ Railgun::Mailer.new(config)
82
+ end
83
+ end
84
+
85
+ it 'properly creates a message body' do
86
+ message = UnitTestMailer.plain_message('test@example.org', 'Test!', {})
87
+ body = Railgun.transform_for_mailgun(message)
88
+
89
+ [:from, :subject, :text, :html, 'to'].each do |param|
90
+ expect(body).to include(param)
91
+ end
92
+
93
+ expect(body[:from][0].value).to eq('unittest@example.org')
94
+ expect(body['to']).to eq(['test@example.org'])
95
+ expect(body[:subject]).to eq(['Test!'])
96
+ expect(body[:text]).to eq(['Test!'])
97
+ expect(body[:html]).to eq(['<p>Test!</p>'.html_safe])
98
+ end
99
+
100
+ it 'adds options to message body' do
101
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
102
+ message.mailgun_options ||= {
103
+ 'tracking-opens' => 'true',
104
+ }
105
+
106
+ body = Railgun.transform_for_mailgun(message)
107
+
108
+ expect(body).to include('o:tracking-opens')
109
+ expect(body['o:tracking-opens']).to eq('true')
110
+ end
111
+
112
+ it 'accepts frozen options to message body' do
113
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
114
+ message.mailgun_options ||= {
115
+ 'tags' => ['some-tag']
116
+ }
117
+
118
+ body = Railgun.transform_for_mailgun(message)
119
+
120
+ expect(body).to include('o:tags')
121
+ expect(body['o:tags']).to eq(['some-tag'])
122
+ end
123
+
124
+ it 'adds variables to message body' do
125
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
126
+ message.mailgun_variables ||= {
127
+ 'user' => {:id => '1', :name => 'tstark'},
128
+ }
129
+
130
+ body = Railgun.transform_for_mailgun(message)
131
+
132
+ expect(body).to include('v:user')
133
+
134
+ var_body = JSON.load(body['v:user'])
135
+ expect(var_body).to include('id')
136
+ expect(var_body).to include('name')
137
+ expect(var_body['id']).to eq('1')
138
+ expect(var_body['name']).to eq('tstark')
139
+ end
140
+
141
+ it 'adds headers to message body' do
142
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
143
+ message.mailgun_headers ||= {
144
+ 'x-unit-test' => 'true',
145
+ }
146
+
147
+ body = Railgun.transform_for_mailgun(message)
148
+
149
+ expect(body).to include('h:x-unit-test')
150
+ expect(body['h:x-unit-test']).to eq('true')
151
+ end
152
+
153
+ it 'adds headers to message body from mailer' do
154
+ message = UnitTestMailer.plain_message('test@example.org', '', {
155
+ 'x-unit-test-2' => 'true',
156
+ })
157
+
158
+ body = Railgun.transform_for_mailgun(message)
159
+
160
+ expect(body).to include('h:x-unit-test-2')
161
+ expect(body['h:x-unit-test-2']).to eq('true')
162
+ end
163
+
164
+ it 'properly handles headers that are passed as separate POST params' do
165
+ message = UnitTestMailer.plain_message('test@example.org', 'Test!', {
166
+ # `From`, `To`, and `Subject` are set on the envelope, so they should be ignored as headers
167
+ 'From' => 'units@example.net',
168
+ 'To' => 'user@example.com',
169
+ 'Subject' => 'This should disappear',
170
+ # If `Bcc` or `Cc` are set as headers, they should be carried over as POST params, not headers
171
+ 'Bcc' => ['list@example.org'],
172
+ 'Cc' => ['admin@example.com'],
173
+ # This is an arbitrary header and should be carried over properly
174
+ 'X-Source' => 'unit tests',
175
+ })
176
+
177
+ body = Railgun.transform_for_mailgun(message)
178
+
179
+ ['From', 'To', 'Subject'].each do |header|
180
+ expect(body).not_to include("h:#{header}")
181
+ end
182
+
183
+ ['bcc', 'cc', 'to', 'h:x-source'].each do |param|
184
+ expect(body).to include(param)
185
+ end
186
+
187
+ expect(body[:from][0].value).to eq('unittest@example.org')
188
+ expect(body['to']).to eq(['test@example.org'])
189
+ expect(body[:subject]).to eq(['Test!'])
190
+ expect(body[:text]).to eq(['Test!'])
191
+ expect(body[:html]).to eq(['<p>Test!</p>'.html_safe])
192
+ expect(body['bcc']).to eq(['list@example.org'])
193
+ expect(body['cc']).to eq(['admin@example.com'])
194
+ expect(body['h:x-source']).to eq('unit tests')
195
+ end
196
+
197
+ context 'when mailgun_variables are present' do
198
+ it 'accepts valid JSON and stores it as message[param].' do
199
+ message = UnitTestMailer.plain_message('test@example.org', '', {}).tap do |message|
200
+ message.mailgun_variables = {
201
+ 'my-data' => '{"key":"value"}'
202
+ }
203
+ end
204
+ body = Railgun.transform_for_mailgun(message)
205
+ expect(body["v:my-data"]).to be_kind_of(String)
206
+ expect(body["v:my-data"].to_s).to eq('{"key":"value"}')
207
+ end
208
+
209
+ it 'accepts a hash and appends as data to the message.' do
210
+ message = UnitTestMailer.plain_message('test@example.org', '', {}).tap do |message|
211
+ message.mailgun_variables = {
212
+ 'my-data' => {'key' => 'value'}
213
+ }
214
+ end
215
+ body = Railgun.transform_for_mailgun(message)
216
+
217
+ expect(body["v:my-data"]).to be_kind_of(String)
218
+ expect(body["v:my-data"].to_s).to eq('{"key":"value"}')
219
+ end
220
+
221
+ it 'accepts string values' do
222
+ message = UnitTestMailer.plain_message('test@example.org', '', {}).tap do |message|
223
+ message.mailgun_variables = {
224
+ 'my-data' => 'String Value.'
225
+ }
226
+ end
227
+ body = Railgun.transform_for_mailgun(message)
228
+
229
+ expect(body["v:my-data"]).to be_kind_of(String)
230
+ expect(body["v:my-data"].to_s).to eq('String Value.')
231
+ end
232
+ end
233
+
234
+ it 'properly adds attachments' do
235
+ message = UnitTestMailer.message_with_attachment('test@example.org', '')
236
+ body = Railgun.transform_for_mailgun(message)
237
+
238
+ expect(body).to include(:attachment)
239
+ attachment = body[:attachment][0]
240
+
241
+ expect(attachment.filename).to eq('info.txt')
242
+ expect(attachment.content_type).to eq('text/plain')
243
+ end
244
+
245
+ it 'delivers!' do
246
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
247
+ message.deliver_now
248
+
249
+ expect(ActionMailer::Base.deliveries).to include(message)
250
+ end
251
+
252
+ it 'ignores `reply-to` in headers' do
253
+ message = UnitTestMailer.plain_message('test@example.org', '', {
254
+ 'reply-to' => 'user@example.com',
255
+ })
256
+ message.mailgun_headers = {
257
+ 'Reply-To' => 'administrator@example.org',
258
+ }
259
+ message.headers({'REPLY-TO' => 'admin@example.net'})
260
+ message.reply_to = "dude@example.com.au"
261
+
262
+ body = Railgun.transform_for_mailgun(message)
263
+ expect(body).to include('h:reply-to')
264
+ expect(body).not_to include('h:Reply-To')
265
+ expect(body['h:reply-to']).to eq('dude@example.com.au')
266
+ end
267
+
268
+ it 'ignores `mime-version` in headers' do
269
+ message = UnitTestMailer.plain_message('test@example.org', '', {
270
+ 'mime-version' => '1.0',
271
+ })
272
+ message.mailgun_headers = {
273
+ 'Mime-Version' => '1.1',
274
+ }
275
+ message.headers({'MIME-VERSION' => '1.2'})
276
+
277
+ body = Railgun.transform_for_mailgun(message)
278
+ expect(body).not_to include('h:mime-version')
279
+ end
280
+
281
+ it 'treats `headers()` names as case-insensitve' do
282
+ message = UnitTestMailer.plain_message('test@example.org', '', {
283
+ 'X-BIG-VALUE' => 1,
284
+ })
285
+
286
+ body = Railgun.transform_for_mailgun(message)
287
+ expect(body).to include('h:x-big-value')
288
+ expect(body['h:x-big-value']).to eq("1")
289
+ end
290
+
291
+ it 'treats `mailgun_headers` names as case-insensitive' do
292
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
293
+ message.mailgun_headers = {
294
+ 'X-BIG-VALUE' => 1,
295
+ }
296
+
297
+ body = Railgun.transform_for_mailgun(message)
298
+ expect(body).to include('h:x-big-value')
299
+ expect(body['h:x-big-value']).to eq("1")
300
+ end
301
+
302
+ it 'handles multi-value, mixed case headers correctly' do
303
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
304
+ message.headers({
305
+ 'x-neat-header' => 'foo',
306
+ 'X-Neat-Header' => 'bar',
307
+ 'X-NEAT-HEADER' => 'zoop',
308
+ })
309
+
310
+ body = Railgun.transform_for_mailgun(message)
311
+ expect(body).to include('h:x-neat-header')
312
+ expect(body['h:x-neat-header']).to include('foo')
313
+ expect(body['h:x-neat-header']).to include('bar')
314
+ expect(body['h:x-neat-header']).to include('zoop')
315
+ end
316
+
317
+ context 'when message with template' do
318
+ it 'adds template header to message from mailer params' do
319
+ template_name = 'template.name'
320
+ message = UnitTestMailer.message_with_template('test@example.org', '', template_name)
321
+
322
+ body = Railgun.transform_for_mailgun(message)
323
+
324
+ expect(body).to include('template')
325
+ expect(body['template']).to eq(template_name)
326
+ end
327
+
328
+ context 'when mailgun_template_variables are assigned' do
329
+ it 'adds template variables to message body' do
330
+ message = UnitTestMailer.message_with_template('test@example.org', '', 'template.name')
331
+ version = 'version_1'
332
+ message.mailgun_template_variables ||= {
333
+ 'version' => version,
334
+ 'text' => 'yes'
335
+ }
336
+
337
+ body = Railgun.transform_for_mailgun(message)
338
+
339
+ expect(body).to include('t:version')
340
+ expect(body['t:version']).to eq('version_1')
341
+ expect(body).to include('t:text')
342
+ expect(body['t:text']).to eq('yes')
343
+ end
344
+ end
345
+ end
346
+
347
+ describe 'deliver!' do
348
+ let(:config) do
349
+ {
350
+ api_key: 'api_key',
351
+ domain: 'domain'
352
+ }
353
+ end
354
+ let(:mail) { UnitTestMailer.plain_message('test@example.org', '', {}) }
355
+ let(:response) do
356
+ response = Struct.new(:code, :id)
357
+ response.new(200, rand(50..100))
358
+ end
359
+
360
+ it 'initiates client message send' do
361
+ result = { from: 'test@example.org' }
362
+ allow(Railgun).to receive(:transform_for_mailgun).and_return(result)
363
+
364
+ expect_any_instance_of(Mailgun::Client).to receive(:send_message)
365
+ .with(config[:domain], result)
366
+ .and_return(response)
367
+ Railgun::Mailer.new(config).deliver!(mail)
368
+ end
369
+
370
+ it 'returns response' do
371
+ expect_any_instance_of(Mailgun::Client).to receive(:send_message).and_return(response)
372
+ expect(Railgun::Mailer.new(config).deliver!(mail)).to eq(response)
373
+ end
374
+
375
+ context 'when domain is provided in arguments' do
376
+ let(:new_domain) { 'new_domain' }
377
+ let(:mail) { UnitTestMailer.message_with_domain('test@example.org', '', new_domain) }
378
+
379
+ it 'uses provided domain' do
380
+ result = { from: 'test@example.org' }
381
+ allow(Railgun).to receive(:transform_for_mailgun).and_return(result)
382
+ expect_any_instance_of(Mailgun::Client).to receive(:send_message)
383
+ .with(new_domain, result).and_return(response)
384
+ Railgun::Mailer.new(config).deliver!(mail)
385
+ end
386
+ end
387
+ end
388
+ end
@@ -2,17 +2,19 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api:<PUBKEY>@api.mailgun.net/v3/address/validate?address=test@DOMAIN.TEST
5
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/address/parse?addresses=Alice%20%3Calice@example.com%3E%3Bbob@example.com%3Bexample.org&syntax_only=true
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
10
  Accept:
11
- - "*/*"
11
+ - '*/*'
12
12
  Accept-Encoding:
13
13
  - gzip, deflate
14
14
  User-Agent:
15
- - Ruby
15
+ - rest-client/2.0.0 (linux-gnu x86_64) ruby/2.3.1p112
16
+ Host:
17
+ - api.mailgun.net
16
18
  response:
17
19
  status:
18
20
  code: 200
@@ -21,15 +23,17 @@ http_interactions:
21
23
  Server:
22
24
  - nginx
23
25
  Date:
24
- - Thu, 07 Jan 2016 22:08:10 GMT
26
+ - Wed, 26 Oct 2016 22:44:07 GMT
25
27
  Content-Type:
26
28
  - application/json
27
29
  Content-Length:
28
- - '247'
30
+ - '118'
29
31
  Connection:
30
32
  - keep-alive
33
+ Content-Disposition:
34
+ - inline
31
35
  Access-Control-Allow-Origin:
32
- - "*"
36
+ - '*'
33
37
  Access-Control-Max-Age:
34
38
  - '600'
35
39
  Access-Control-Allow-Methods:
@@ -40,30 +44,86 @@ http_interactions:
40
44
  encoding: UTF-8
41
45
  string: |-
42
46
  {
43
- "address": "test@DOMAIN.TEST",
47
+ "parsed": [
48
+ "Alice <alice@example.com>",
49
+ "bob@example.com"
50
+ ],
51
+ "unparseable": [
52
+ "example.org"
53
+ ]
54
+ }
55
+ http_version:
56
+ recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
57
+ - request:
58
+ method: get
59
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/address/validate?address=alice@mailgun.net
60
+ body:
61
+ encoding: US-ASCII
62
+ string: ''
63
+ headers:
64
+ Accept:
65
+ - '*/*'
66
+ Accept-Encoding:
67
+ - gzip, deflate
68
+ User-Agent:
69
+ - rest-client/2.0.0 (linux-gnu x86_64) ruby/2.3.1p112
70
+ Host:
71
+ - api.mailgun.net
72
+ response:
73
+ status:
74
+ code: 200
75
+ message: OK
76
+ headers:
77
+ Server:
78
+ - nginx
79
+ Date:
80
+ - Wed, 26 Oct 2016 22:44:08 GMT
81
+ Content-Type:
82
+ - application/json
83
+ Content-Length:
84
+ - '179'
85
+ Connection:
86
+ - keep-alive
87
+ Content-Disposition:
88
+ - inline
89
+ Access-Control-Allow-Origin:
90
+ - '*'
91
+ Access-Control-Max-Age:
92
+ - '600'
93
+ Access-Control-Allow-Methods:
94
+ - GET, POST, PUT, DELETE, OPTIONS
95
+ Access-Control-Allow-Headers:
96
+ - Content-Type, x-requested-with
97
+ body:
98
+ encoding: UTF-8
99
+ string: |-
100
+ {
101
+ "address": "alice@mailgun.net",
44
102
  "did_you_mean": null,
45
103
  "is_valid": true,
46
104
  "parts": {
47
105
  "display_name": null,
48
- "domain": "DOMAIN.TEST",
49
- "local_part": "test"
106
+ "domain": "mailgun.net",
107
+ "local_part": "alice"
50
108
  }
51
109
  }
52
110
  http_version:
53
- recorded_at: Thu, 07 Jan 2016 22:08:10 GMT
111
+ recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
54
112
  - request:
55
113
  method: get
56
- uri: https://api:<PUBKEY>@api.mailgun.net/v3/address/parse?addresses=Alice%20%3Calice@DOMAIN.TEST%3E,bob@DOMAIN.TEST,DOMAIN.TEST
114
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/address/validate?address=example.org
57
115
  body:
58
116
  encoding: US-ASCII
59
117
  string: ''
60
118
  headers:
61
119
  Accept:
62
- - "*/*"
120
+ - '*/*'
63
121
  Accept-Encoding:
64
122
  - gzip, deflate
65
123
  User-Agent:
66
- - Ruby
124
+ - rest-client/2.0.0 (linux-gnu x86_64) ruby/2.3.1p112
125
+ Host:
126
+ - api.mailgun.net
67
127
  response:
68
128
  status:
69
129
  code: 200
@@ -72,15 +132,17 @@ http_interactions:
72
132
  Server:
73
133
  - nginx
74
134
  Date:
75
- - Thu, 07 Jan 2016 22:08:10 GMT
135
+ - Wed, 26 Oct 2016 22:44:08 GMT
76
136
  Content-Type:
77
137
  - application/json
78
138
  Content-Length:
79
- - '223'
139
+ - '162'
80
140
  Connection:
81
141
  - keep-alive
142
+ Content-Disposition:
143
+ - inline
82
144
  Access-Control-Allow-Origin:
83
- - "*"
145
+ - '*'
84
146
  Access-Control-Max-Age:
85
147
  - '600'
86
148
  Access-Control-Allow-Methods:
@@ -91,14 +153,63 @@ http_interactions:
91
153
  encoding: UTF-8
92
154
  string: |-
93
155
  {
94
- "parsed": [
95
- "Alice <alice@DOMAIN.TEST>",
96
- "bob@DOMAIN.TEST"
97
- ],
98
- "unparseable": [
99
- "DOMAIN.TEST"
100
- ]
156
+ "address": "example.org",
157
+ "did_you_mean": null,
158
+ "is_valid": false,
159
+ "parts": {
160
+ "display_name": null,
161
+ "domain": null,
162
+ "local_part": null
163
+ }
101
164
  }
102
165
  http_version:
103
- recorded_at: Thu, 07 Jan 2016 22:08:10 GMT
104
- recorded_with: VCR 3.0.1
166
+ recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
167
+ - request:
168
+ method: get
169
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/address/validate?address=alice@mailgun.net&mailbox_verification=true
170
+ body:
171
+ encoding: US-ASCII
172
+ string: ''
173
+ headers:
174
+ Accept:
175
+ - '*/*'
176
+ Accept-Encoding:
177
+ - gzip, deflate
178
+ User-Agent:
179
+ - rest-client/2.0.2 (darwin16.7.0 x86_64) ruby/2.0.0p0
180
+ Host:
181
+ - api.mailgun.net
182
+ response:
183
+ status:
184
+ code: 200
185
+ message: OK
186
+ headers:
187
+ Access-Control-Allow-Headers:
188
+ - Content-Type, x-requested-with
189
+ Access-Control-Allow-Methods:
190
+ - GET, POST, PUT, DELETE, OPTIONS
191
+ Access-Control-Allow-Origin:
192
+ - '*'
193
+ Access-Control-Max-Age:
194
+ - '600'
195
+ Content-Disposition:
196
+ - inline
197
+ Content-Type:
198
+ - application/json
199
+ Date:
200
+ - Tue, 12 Sep 2017 16:55:09 GMT
201
+ Server:
202
+ - nginx
203
+ Content-Length:
204
+ - '243'
205
+ Connection:
206
+ - keep-alive
207
+ body:
208
+ encoding: UTF-8
209
+ string: '{"address": "alice@mailgun.net", "did_you_mean": null, "is_disposable_address":
210
+ false, "is_role_address": false, "is_valid": true, "mailbox_verification":
211
+ "true", "parts": {"display_name": null, "domain": "mailgun.net", "local_part":
212
+ "alice"}}'
213
+ http_version:
214
+ recorded_at: Tue, 12 Sep 2017 16:55:09 GMT
215
+ recorded_with: VCR 3.0.3