mailgun-ruby 1.2.0 → 1.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/docs/Domains.md +3 -0
- data/docs/OptInHandler.md +1 -1
- data/docs/Snippets.md +54 -61
- data/docs/railgun/Templates.md +92 -0
- data/lib/mailgun/address.rb +3 -28
- data/lib/mailgun/client.rb +43 -10
- data/lib/mailgun/domains/domains.rb +19 -1
- data/lib/mailgun/exceptions/exceptions.rb +28 -1
- data/lib/mailgun/messages/batch_message.rb +1 -0
- data/lib/mailgun/messages/message_builder.rb +55 -7
- data/lib/mailgun/suppressions.rb +15 -8
- data/lib/mailgun/version.rb +1 -1
- data/lib/mailgun-ruby.rb +1 -1
- data/lib/mailgun.rb +3 -1
- data/lib/railgun/mailer.rb +30 -9
- data/lib/railgun/message.rb +2 -1
- data/lib/railgun/railtie.rb +3 -2
- data/mailgun.gemspec +1 -1
- data/spec/integration/bounces_spec.rb +3 -3
- data/spec/integration/domains_spec.rb +8 -0
- data/spec/integration/email_validation_spec.rb +1 -8
- data/spec/integration/mailer_spec.rb +67 -0
- data/spec/integration/mailgun_spec.rb +76 -1
- data/spec/integration/suppressions_spec.rb +18 -2
- data/spec/unit/connection/test_client.rb +18 -1
- data/spec/unit/mailgun_spec.rb +43 -2
- data/spec/unit/messages/batch_message_spec.rb +56 -40
- data/spec/unit/messages/message_builder_spec.rb +149 -16
- data/spec/unit/messages/sample_data/unknown.type +0 -0
- data/spec/unit/railgun/mailer_spec.rb +171 -0
- data/vcr_cassettes/bounces.yml +12 -12
- data/vcr_cassettes/domains.yml +51 -1
- data/vcr_cassettes/exceptions-invalid-api-key.yml +52 -0
- data/vcr_cassettes/exceptions-invalid-data.yml +52 -0
- data/vcr_cassettes/exceptions-not-allowed.yml +54 -0
- data/vcr_cassettes/mailer_invalid_domain.yml +109 -0
- data/vcr_cassettes/message_deliver.yml +149 -0
- data/vcr_cassettes/suppressions.yml +66 -15
- metadata +15 -6
@@ -31,6 +31,18 @@ class UnitTestMailer < ActionMailer::Base
|
|
31
31
|
end
|
32
32
|
end
|
33
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
|
+
|
34
46
|
end
|
35
47
|
|
36
48
|
describe 'Railgun::Mailer' do
|
@@ -45,6 +57,31 @@ describe 'Railgun::Mailer' do
|
|
45
57
|
expect(@mailer_obj.mailgun_client).to be_a(Mailgun::Client)
|
46
58
|
end
|
47
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
|
+
|
48
85
|
it 'properly creates a message body' do
|
49
86
|
message = UnitTestMailer.plain_message('test@example.org', 'Test!', {})
|
50
87
|
body = Railgun.transform_for_mailgun(message)
|
@@ -72,6 +109,18 @@ describe 'Railgun::Mailer' do
|
|
72
109
|
expect(body['o:tracking-opens']).to eq('true')
|
73
110
|
end
|
74
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
|
+
|
75
124
|
it 'adds variables to message body' do
|
76
125
|
message = UnitTestMailer.plain_message('test@example.org', '', {})
|
77
126
|
message.mailgun_variables ||= {
|
@@ -145,6 +194,43 @@ describe 'Railgun::Mailer' do
|
|
145
194
|
expect(body['h:x-source']).to eq('unit tests')
|
146
195
|
end
|
147
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
|
+
|
148
234
|
it 'properly adds attachments' do
|
149
235
|
message = UnitTestMailer.message_with_attachment('test@example.org', '')
|
150
236
|
body = Railgun.transform_for_mailgun(message)
|
@@ -179,6 +265,19 @@ describe 'Railgun::Mailer' do
|
|
179
265
|
expect(body['h:reply-to']).to eq('dude@example.com.au')
|
180
266
|
end
|
181
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
|
+
|
182
281
|
it 'treats `headers()` names as case-insensitve' do
|
183
282
|
message = UnitTestMailer.plain_message('test@example.org', '', {
|
184
283
|
'X-BIG-VALUE' => 1,
|
@@ -214,4 +313,76 @@ describe 'Railgun::Mailer' do
|
|
214
313
|
expect(body['h:x-neat-header']).to include('bar')
|
215
314
|
expect(body['h:x-neat-header']).to include('zoop')
|
216
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
|
217
388
|
end
|
data/vcr_cassettes/bounces.yml
CHANGED
@@ -5,7 +5,7 @@ http_interactions:
|
|
5
5
|
uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
|
-
string: address=integration-test
|
8
|
+
string: address=integration-test%2Bemail%40DOMAIN.TEST&code=550&error=Integration%20Test
|
9
9
|
headers:
|
10
10
|
Accept:
|
11
11
|
- "*/*; q=0.5, application/xml"
|
@@ -42,13 +42,13 @@ http_interactions:
|
|
42
42
|
- Content-Type, x-requested-with
|
43
43
|
body:
|
44
44
|
encoding: UTF-8
|
45
|
-
string: '{"address":"integration-test
|
45
|
+
string: '{"address":"integration-test+email@DOMAIN.TEST","message":"Address
|
46
46
|
has been added to the bounces table"}'
|
47
|
-
http_version:
|
47
|
+
http_version:
|
48
48
|
recorded_at: Fri, 08 Jan 2016 20:33:29 GMT
|
49
49
|
- request:
|
50
50
|
method: get
|
51
|
-
uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces/integration-test
|
51
|
+
uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces/integration-test+email@DOMAIN.TEST
|
52
52
|
body:
|
53
53
|
encoding: US-ASCII
|
54
54
|
string: ''
|
@@ -84,9 +84,9 @@ http_interactions:
|
|
84
84
|
- Content-Type, x-requested-with
|
85
85
|
body:
|
86
86
|
encoding: UTF-8
|
87
|
-
string: '{"address":"integration-test
|
87
|
+
string: '{"address":"integration-test+email@DOMAIN.TEST","code":"550","error":"Integration
|
88
88
|
Test","created_at":"Fri, 08 Jan 2016 20:33:28 UTC"}'
|
89
|
-
http_version:
|
89
|
+
http_version:
|
90
90
|
recorded_at: Fri, 08 Jan 2016 20:33:29 GMT
|
91
91
|
- request:
|
92
92
|
method: get
|
@@ -126,13 +126,13 @@ http_interactions:
|
|
126
126
|
- Content-Type, x-requested-with
|
127
127
|
body:
|
128
128
|
encoding: UTF-8
|
129
|
-
string: '{"items":[{"address":"integration-test
|
130
|
-
Test","created_at":"Fri, 08 Jan 2016 20:33:28 UTC"}],"paging":{"first":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?limit=100","last":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=last\u0026limit=100","next":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=next\u0026address=integration-test
|
131
|
-
http_version:
|
129
|
+
string: '{"items":[{"address":"integration-test+email@DOMAIN.TEST","code":"550","error":"Integration
|
130
|
+
Test","created_at":"Fri, 08 Jan 2016 20:33:28 UTC"}],"paging":{"first":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?limit=100","last":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=last\u0026limit=100","next":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=next\u0026address=integration-test%2Bemaill%40DOMAIN.TEST\u0026limit=100","previous":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=previous\u0026address=integration-test%2Bemail%40DOMAIN.TEST\u0026limit=100"}}'
|
131
|
+
http_version:
|
132
132
|
recorded_at: Fri, 08 Jan 2016 20:33:29 GMT
|
133
133
|
- request:
|
134
134
|
method: delete
|
135
|
-
uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces/integration-test
|
135
|
+
uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces/integration-test+email@DOMAIN.TEST
|
136
136
|
body:
|
137
137
|
encoding: US-ASCII
|
138
138
|
string: ''
|
@@ -168,8 +168,8 @@ http_interactions:
|
|
168
168
|
- Content-Type, x-requested-with
|
169
169
|
body:
|
170
170
|
encoding: UTF-8
|
171
|
-
string: '{"address":"integration-test
|
171
|
+
string: '{"address":"integration-test+email@DOMAIN.TEST","message":"Bounced
|
172
172
|
address has been removed"}'
|
173
|
-
http_version:
|
173
|
+
http_version:
|
174
174
|
recorded_at: Fri, 08 Jan 2016 20:33:30 GMT
|
175
175
|
recorded_with: VCR 3.0.1
|
data/vcr_cassettes/domains.yml
CHANGED
@@ -357,4 +357,54 @@ http_interactions:
|
|
357
357
|
}
|
358
358
|
http_version:
|
359
359
|
recorded_at: Fri, 15 Jan 2016 20:12:54 GMT
|
360
|
-
|
360
|
+
- request:
|
361
|
+
method: put
|
362
|
+
uri: https://api.mailgun.net/v3/domains/integration-test.domain.invalid
|
363
|
+
body:
|
364
|
+
encoding: UTF-8
|
365
|
+
string: spam_action=block&web_scheme=https&wildcard=true
|
366
|
+
headers:
|
367
|
+
Accept:
|
368
|
+
- "*/*"
|
369
|
+
User-Agent:
|
370
|
+
- rest-client/2.1.0 (darwin21.6.0 x86_64) ruby/2.5.1p57
|
371
|
+
Content-Length:
|
372
|
+
- '48'
|
373
|
+
Content-Type:
|
374
|
+
- application/x-www-form-urlencoded
|
375
|
+
Accept-Encoding:
|
376
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
377
|
+
Host:
|
378
|
+
- api.mailgun.net
|
379
|
+
Authorization:
|
380
|
+
- Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
|
381
|
+
response:
|
382
|
+
status:
|
383
|
+
code: 200
|
384
|
+
message: OK
|
385
|
+
headers:
|
386
|
+
Access-Control-Allow-Credentials:
|
387
|
+
- 'true'
|
388
|
+
Access-Control-Allow-Origin:
|
389
|
+
- "*"
|
390
|
+
Cache-Control:
|
391
|
+
- no-store
|
392
|
+
Content-Length:
|
393
|
+
- '445'
|
394
|
+
Content-Type:
|
395
|
+
- application/json; charset=utf-8
|
396
|
+
Date:
|
397
|
+
- Mon, 17 Apr 2023 13:03:16 GMT
|
398
|
+
Strict-Transport-Security:
|
399
|
+
- max-age=63072000; includeSubDomains
|
400
|
+
X-Xss-Protection:
|
401
|
+
- 1; mode=block
|
402
|
+
body:
|
403
|
+
encoding: UTF-8
|
404
|
+
string: '{"message":"Domain has been updated","domain":{"created_at":"Mon, 25
|
405
|
+
Jan 2021 10:11:26 GMT","id":"600e994e20b1a14a5990856d","is_disabled":false,"name":"integration-test.domain.invalid","require_tls":false,"skip_verification":false,"smtp_login":"postmaster@DOMAIN.TEST","spam_action":"block","state":"active","type":"sandbox","web_prefix":"email","web_scheme":"https","wildcard":true}}
|
406
|
+
|
407
|
+
'
|
408
|
+
http_version:
|
409
|
+
recorded_at: Mon, 17 Apr 2023 13:04:47 GMT
|
410
|
+
recorded_with: VCR 3.0.3
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: from=sally%test.com&to=sally%test.com&subject=Exception+Integration+Test&text=INTEGRATION+TESTING
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
User-Agent:
|
13
|
+
- rest-client/2.1.0 (darwin21.6.0 x86_64) ruby/2.5.1p57
|
14
|
+
Content-Length:
|
15
|
+
- '119'
|
16
|
+
Content-Type:
|
17
|
+
- application/x-www-form-urlencoded
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
Host:
|
21
|
+
- api.mailgun.net
|
22
|
+
Authorization:
|
23
|
+
- Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2YwNS1mYTQ4MTZhMQ==
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 401
|
27
|
+
message: Unauthorized
|
28
|
+
headers:
|
29
|
+
Access-Control-Allow-Credentials:
|
30
|
+
- 'true'
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Cache-Control:
|
34
|
+
- no-store
|
35
|
+
Content-Length:
|
36
|
+
- '9'
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset=utf-8
|
39
|
+
Date:
|
40
|
+
- Sun, 28 May 2023 11:29:25 GMT
|
41
|
+
Strict-Transport-Security:
|
42
|
+
- max-age=63072000; includeSubDomains
|
43
|
+
Www-Authenticate:
|
44
|
+
- Basic realm="MG API"
|
45
|
+
X-Xss-Protection:
|
46
|
+
- 1; mode=block
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: Forbidden
|
50
|
+
http_version:
|
51
|
+
recorded_at: Sun, 28 May 2023 11:29:25 GMT
|
52
|
+
recorded_with: VCR 3.0.3
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: from=sally%40gmail.com&to=sallygmail.com&subject=Exception+Integration+Test&text=INTEGRATION+TESTING
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
User-Agent:
|
13
|
+
- rest-client/2.1.0 (darwin21.6.0 x86_64) ruby/2.5.1p57
|
14
|
+
Content-Length:
|
15
|
+
- '116'
|
16
|
+
Content-Type:
|
17
|
+
- application/x-www-form-urlencoded
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
Host:
|
21
|
+
- api.mailgun.net
|
22
|
+
Authorization:
|
23
|
+
- Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 400
|
27
|
+
message: Bad Request
|
28
|
+
headers:
|
29
|
+
Access-Control-Allow-Credentials:
|
30
|
+
- 'true'
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Cache-Control:
|
34
|
+
- no-store
|
35
|
+
Content-Length:
|
36
|
+
- '78'
|
37
|
+
Content-Type:
|
38
|
+
- application/json; charset=utf-8
|
39
|
+
Date:
|
40
|
+
- Sun, 28 May 2023 11:35:04 GMT
|
41
|
+
Strict-Transport-Security:
|
42
|
+
- max-age=63072000; includeSubDomains
|
43
|
+
X-Xss-Protection:
|
44
|
+
- 1; mode=block
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"message":"to parameter is not a valid address. please check documentation"}
|
48
|
+
|
49
|
+
'
|
50
|
+
http_version:
|
51
|
+
recorded_at: Sun, 28 May 2023 11:35:04 GMT
|
52
|
+
recorded_with: VCR 3.0.3
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: from=sally%test.com&to=sally%test.com&subject=Exception+Integration+Test&text=INTEGRATION+TESTING
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
User-Agent:
|
13
|
+
- rest-client/2.1.0 (darwin21.6.0 x86_64) ruby/2.5.1p57
|
14
|
+
Content-Length:
|
15
|
+
- '121'
|
16
|
+
Content-Type:
|
17
|
+
- application/x-www-form-urlencoded
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
Host:
|
21
|
+
- api.mailgun.net
|
22
|
+
Authorization:
|
23
|
+
- Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 403
|
27
|
+
message: Forbidden
|
28
|
+
headers:
|
29
|
+
Access-Control-Allow-Credentials:
|
30
|
+
- 'true'
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Cache-Control:
|
34
|
+
- no-store
|
35
|
+
Content-Length:
|
36
|
+
- '219'
|
37
|
+
Content-Type:
|
38
|
+
- application/json; charset=utf-8
|
39
|
+
Date:
|
40
|
+
- Sun, 28 May 2023 11:40:00 GMT
|
41
|
+
Strict-Transport-Security:
|
42
|
+
- max-age=63072000; includeSubDomains
|
43
|
+
X-Xss-Protection:
|
44
|
+
- 1; mode=block
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"message":"Domain DOMAIN.TEST is not allowed to send: Free accounts
|
48
|
+
are for test purposes only. Please upgrade or add the address to authorized
|
49
|
+
recipients in Account Settings."}
|
50
|
+
|
51
|
+
'
|
52
|
+
http_version:
|
53
|
+
recorded_at: Sun, 28 May 2023 11:40:00 GMT
|
54
|
+
recorded_with: VCR 3.0.3
|
@@ -0,0 +1,109 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.mailgun.net/v3/not-our-doma.in/messages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: from[]=sally%40not-our-doma.in&subject[]=subject&html[]=%3Cp%3ETest%21%3C%2Fp%3E&text[]=Test%21&to[]=bob%40DOMAIN.TEST&h%3Acontent-type=multipart%2Falternative%3B+boundary%3D%22--%3D%3D_mimepart_6098fb5a12edf_78633ff4e00521889696a%22%3B+charset%3DUTF-8
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
User-Agent:
|
13
|
+
- rest-client/2.1.0 (darwin18.7.0 x86_64) ruby/2.2.2p95
|
14
|
+
Content-Length:
|
15
|
+
- '262'
|
16
|
+
Content-Type:
|
17
|
+
- application/x-www-form-urlencoded
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
Host:
|
21
|
+
- api.mailgun.net
|
22
|
+
Authorization:
|
23
|
+
- Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 401
|
27
|
+
message: UNAUTHORIZED
|
28
|
+
headers:
|
29
|
+
Access-Control-Allow-Headers:
|
30
|
+
- Content-Type, x-requested-with, Authorization
|
31
|
+
Access-Control-Allow-Methods:
|
32
|
+
- GET, POST, PUT, DELETE, OPTIONS
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- "*"
|
35
|
+
Access-Control-Max-Age:
|
36
|
+
- '600'
|
37
|
+
Cache-Control:
|
38
|
+
- no-store
|
39
|
+
Content-Type:
|
40
|
+
- text/html; charset=utf-8
|
41
|
+
Date:
|
42
|
+
- Mon, 10 May 2021 09:22:34 GMT
|
43
|
+
Server:
|
44
|
+
- nginx
|
45
|
+
Www-Authenticate:
|
46
|
+
- Basic realm="MG API"
|
47
|
+
Content-Length:
|
48
|
+
- '9'
|
49
|
+
Connection:
|
50
|
+
- keep-alive
|
51
|
+
body:
|
52
|
+
encoding: UTF-8
|
53
|
+
string: Forbidden
|
54
|
+
http_version:
|
55
|
+
recorded_at: Mon, 10 May 2021 09:22:34 GMT
|
56
|
+
- request:
|
57
|
+
method: post
|
58
|
+
uri: https://api.mailgun.net/v3/not-our-doma.in/messages
|
59
|
+
body:
|
60
|
+
encoding: US-ASCII
|
61
|
+
string: from[]=sally%40not-our-doma.in&subject[]=subject&html[]=%3Cp%3ETest%21%3C%2Fp%3E&text[]=Test%21&to[]=bob%40DOMAIN.TEST&h%3Acontent-type=multipart%2Falternative%3B+boundary%3D%22--%3D%3D_mimepart_6098fb5a12edf_78633ff4e00521889696a%22%3B+charset%3DUTF-8
|
62
|
+
headers:
|
63
|
+
Accept:
|
64
|
+
- "*/*"
|
65
|
+
User-Agent:
|
66
|
+
- rest-client/2.1.0 (darwin18.7.0 x86_64) ruby/2.2.2p95
|
67
|
+
Content-Length:
|
68
|
+
- '262'
|
69
|
+
Content-Type:
|
70
|
+
- application/x-www-form-urlencoded
|
71
|
+
Accept-Encoding:
|
72
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
73
|
+
Host:
|
74
|
+
- api.mailgun.net
|
75
|
+
Authorization:
|
76
|
+
- Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
|
77
|
+
response:
|
78
|
+
status:
|
79
|
+
code: 401
|
80
|
+
message: UNAUTHORIZED
|
81
|
+
headers:
|
82
|
+
Access-Control-Allow-Headers:
|
83
|
+
- Content-Type, x-requested-with, Authorization
|
84
|
+
Access-Control-Allow-Methods:
|
85
|
+
- GET, POST, PUT, DELETE, OPTIONS
|
86
|
+
Access-Control-Allow-Origin:
|
87
|
+
- "*"
|
88
|
+
Access-Control-Max-Age:
|
89
|
+
- '600'
|
90
|
+
Cache-Control:
|
91
|
+
- no-store
|
92
|
+
Content-Type:
|
93
|
+
- text/html; charset=utf-8
|
94
|
+
Date:
|
95
|
+
- Mon, 10 May 2021 09:22:40 GMT
|
96
|
+
Server:
|
97
|
+
- nginx
|
98
|
+
Www-Authenticate:
|
99
|
+
- Basic realm="MG API"
|
100
|
+
Content-Length:
|
101
|
+
- '9'
|
102
|
+
Connection:
|
103
|
+
- keep-alive
|
104
|
+
body:
|
105
|
+
encoding: UTF-8
|
106
|
+
string: Forbidden
|
107
|
+
http_version:
|
108
|
+
recorded_at: Mon, 10 May 2021 09:22:40 GMT
|
109
|
+
recorded_with: VCR 3.0.3
|