mailgun-ruby 1.2.5 → 1.2.10

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.
@@ -53,8 +53,9 @@ module Mailgun
53
53
  # domain - [String] Name of the domain (ex. domain.com)
54
54
  # options - [Hash] of
55
55
  # smtp_password - [String] Password for SMTP authentication
56
- # spam_action - [String] disabled or tag
56
+ # spam_action - [String] disabled, blocked or tag
57
57
  # Disable, no spam filtering will occur for inbound messages.
58
+ # Block, inbound spam messages will not be delivered.
58
59
  # Tag, messages will be tagged wtih a spam header. See Spam Filter.
59
60
  # wildcard - [Boolean] true or false Determines whether the domain will accept email for sub-domains.
60
61
  #
@@ -80,5 +81,22 @@ module Mailgun
80
81
  alias_method :delete, :remove
81
82
  alias_method :delete_domain, :remove
82
83
 
84
+ # Public: Update domain
85
+ #
86
+ # domain - [String] Name of the domain (ex. domain.com)
87
+ # options - [Hash] of
88
+ # spam_action - [String] disabled, blocked or tag
89
+ # Disable, no spam filtering will occur for inbound messages.
90
+ # Block, inbound spam messages will not be delivered.
91
+ # Tag, messages will be tagged wtih a spam header. See Spam Filter.
92
+ # web_scheme - [String] http or https
93
+ # Set your open, click and unsubscribe URLs to use http or https
94
+ # wildcard - [Boolean] true or false Determines whether the domain will accept email for sub-domains.
95
+ #
96
+ # Returns [Hash] of updated domain
97
+ def update(domain, options = {})
98
+ fail(ParameterError, 'No domain given to add on Mailgun', caller) unless domain
99
+ @client.put("domains/#{domain}", options).to_h
100
+ end
83
101
  end
84
102
  end
@@ -43,7 +43,11 @@ module Mailgun
43
43
  #
44
44
  def initialize(message = nil, response = nil)
45
45
  @response = response
46
- @code = response.code || NOCODE
46
+ @code = if response.nil?
47
+ NOCODE
48
+ else
49
+ response.code
50
+ end
47
51
 
48
52
  begin
49
53
  api_message = JSON.parse(response.body)['message']
@@ -51,8 +55,9 @@ module Mailgun
51
55
  api_message = response.body
52
56
  rescue NoMethodError
53
57
  api_message = "Unknown API error"
58
+ rescue
59
+ api_message = 'Unknown API error'
54
60
  end
55
- api_message = api_message + ' - Invalid Domain or API key' if api_message == FORBIDDEN
56
61
 
57
62
  message = message || ''
58
63
  message = message + ': ' + api_message
@@ -62,6 +67,26 @@ module Mailgun
62
67
  @code = NOCODE
63
68
  super(message, response)
64
69
  end
70
+ end
71
+
72
+ # Public: Class for managing unauthorized 401 errors
73
+ # Inherits from Mailgun::CommunicationError
74
+ class Unauthorized < CommunicationError
75
+ CODE = 401
65
76
 
77
+ def initialize(error_message, response)
78
+ error_message = error_message + ' - Invalid Domain or API key'
79
+ super(error_message, response)
80
+ end
81
+ end
82
+
83
+ # Public: Class for managing bad request 400 errors
84
+ # Inherits from Mailgun::CommunicationError
85
+ class BadRequest < CommunicationError
86
+ CODE = 400
87
+
88
+ def initialize(error_message, response)
89
+ super(error_message, response)
90
+ end
66
91
  end
67
92
  end
@@ -406,7 +406,7 @@ module Mailgun
406
406
  def make_json(obj)
407
407
  return JSON.parse(obj).to_json if obj.is_a?(String)
408
408
  return obj.to_json if obj.is_a?(Hash)
409
- return JSON.generate(obj).to_json
409
+ JSON.generate(obj).to_json
410
410
  rescue
411
411
  raise Mailgun::ParameterError, 'Provided data could not be made into JSON. Try a JSON string or Hash.', obj
412
412
  end
@@ -429,7 +429,7 @@ module Mailgun
429
429
  full_name = vars['full_name']
430
430
  elsif vars['first'] || vars['last']
431
431
  full_name = "#{vars['first']} #{vars['last']}".strip
432
- end
432
+ end
433
433
 
434
434
  return "'#{full_name}' <#{address}>" if full_name
435
435
  address
@@ -45,11 +45,11 @@ module Mailgun
45
45
  end
46
46
 
47
47
  def get_bounce(address)
48
- @client.get("#{@domain}/bounces/#{address}", nil)
48
+ @client.get("#{@domain}/bounces/#{escape_address(address)}", nil)
49
49
  end
50
50
 
51
51
  def create_bounce(params = {})
52
- @client.post("#{@domain/bounces}", params)
52
+ @client.post("#{@domain}/bounces", params)
53
53
  end
54
54
 
55
55
  # Creates multiple bounces on the Mailgun API.
@@ -100,7 +100,7 @@ module Mailgun
100
100
  end
101
101
 
102
102
  def delete_bounce(address)
103
- @client.delete("#{@domain}/bounces/#{address}")
103
+ @client.delete("#{@domain}/bounces/#{escape_address(address)}")
104
104
  end
105
105
 
106
106
  def delete_all_bounces
@@ -118,7 +118,7 @@ module Mailgun
118
118
  end
119
119
 
120
120
  def get_unsubscribe(address)
121
- @client.get("#{@domain}/unsubscribes/#{address}")
121
+ @client.get("#{@domain}/unsubscribes/#{escape_address(address)}")
122
122
  end
123
123
 
124
124
  def create_unsubscribe(params = {})
@@ -173,7 +173,7 @@ module Mailgun
173
173
  end
174
174
 
175
175
  def delete_unsubscribe(address, params = {})
176
- @client.delete("#{@domain}/unsubscribes/#{address}")
176
+ @client.delete("#{@domain}/unsubscribes/#{escape_address(address)}")
177
177
  end
178
178
 
179
179
  ####
@@ -187,7 +187,7 @@ module Mailgun
187
187
  end
188
188
 
189
189
  def get_complaint(address)
190
- @client.get("#{@domain}/complaints/#{address}", nil)
190
+ @client.get("#{@domain}/complaints/#{escape_address(address)}", nil)
191
191
  end
192
192
 
193
193
  def create_complaint(params = {})
@@ -239,11 +239,15 @@ module Mailgun
239
239
  end
240
240
 
241
241
  def delete_complaint(address)
242
- @client.delete("#{@domain}/complaints/#{address}")
242
+ @client.delete("#{@domain}/complaints/#{escape_address(address)}")
243
243
  end
244
244
 
245
245
  private
246
246
 
247
+ def escape_address(address)
248
+ CGI.escape address
249
+ end
250
+
247
251
  def get_from_paging(uri, params = {})
248
252
  @client.get(uri, params)
249
253
  end
@@ -1,4 +1,4 @@
1
1
  # It's the version. Yeay!
2
2
  module Mailgun
3
- VERSION = '1.2.5'
3
+ VERSION = '1.2.10'
4
4
  end
data/lib/mailgun-ruby.rb CHANGED
@@ -1,2 +1,2 @@
1
1
  require 'mailgun'
2
- require 'railgun' if defined?(Rails)
2
+ require 'railgun' if defined?(Rails) && defined?(ActionMailer)
data/lib/mailgun.rb CHANGED
@@ -22,10 +22,12 @@ require 'mailgun/webhooks/webhooks'
22
22
  module Mailgun
23
23
 
24
24
  class << self
25
- attr_accessor :api_key,
25
+ attr_accessor :api_host,
26
+ :api_key,
26
27
  :api_version,
27
28
  :protocol,
28
29
  :mailgun_host,
30
+ :proxy_url,
29
31
  :test_mode,
30
32
  :domain
31
33
 
@@ -33,7 +33,7 @@ module Railgun
33
33
  config[:api_version] || 'v3',
34
34
  config[:api_ssl].nil? ? true : config[:api_ssl],
35
35
  false,
36
- config[:timeout],
36
+ config[:timeout]
37
37
  )
38
38
  @domain = @config[:domain]
39
39
 
@@ -48,7 +48,10 @@ module Railgun
48
48
 
49
49
  def deliver!(mail)
50
50
  @mg_domain = set_mg_domain(mail)
51
+ @mg_client.set_api_key(mail[:api_key].value) if mail[:api_key].present?
52
+
51
53
  mail[:domain] = nil if mail[:domain].present?
54
+ mail[:api_key] = nil if mail[:api_key].present?
52
55
 
53
56
  mg_message = Railgun.transform_for_mailgun(mail)
54
57
  response = @mg_client.send_message(@mg_domain, mg_message)
@@ -7,7 +7,7 @@ describe 'For the Bounces endpoint', order: :defined, vcr: vcr_opts do
7
7
  before(:all) do
8
8
  @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
9
9
  @domain = TESTDOMAIN
10
- @email = "integration-test-email@#{TESTDOMAIN}"
10
+ @email = "integration-test+email@#{TESTDOMAIN}"
11
11
  end
12
12
 
13
13
  it 'creates a bounce' do
@@ -22,7 +22,7 @@ describe 'For the Bounces endpoint', order: :defined, vcr: vcr_opts do
22
22
  end
23
23
 
24
24
  it 'get a bounce.' do
25
- result = @mg_obj.get("#{@domain}/bounces/#{@email}")
25
+ result = @mg_obj.get("#{@domain}/bounces/#{CGI.escape(@email)}")
26
26
 
27
27
  result.to_h!
28
28
  expect(result.body["code"]).to eq("550")
@@ -38,7 +38,7 @@ describe 'For the Bounces endpoint', order: :defined, vcr: vcr_opts do
38
38
  end
39
39
 
40
40
  it 'deletes a bounce' do
41
- @mg_obj.delete("#{@domain}/bounces/#{@email}")
41
+ @mg_obj.delete("#{@domain}/bounces/#{CGI.escape(@email)}")
42
42
  end
43
43
 
44
44
  end
@@ -36,4 +36,12 @@ describe 'For the domains endpoint', vcr: vcr_opts do
36
36
 
37
37
  expect(result).to be_truthy
38
38
  end
39
+
40
+ it 'updates the domain' do
41
+ result = @mg_obj.update(@domain, { spam_action: 'block', web_scheme: 'https', wildcard: true })
42
+
43
+ expect(result['domain']["spam_action"]).to eq('block')
44
+ expect(result['domain']["web_scheme"]).to eq('https')
45
+ expect(result['domain']["wildcard"]).to eq(true)
46
+ end
39
47
  end
@@ -7,7 +7,7 @@ vcr_opts = { :cassette_name => "email_validation" }
7
7
 
8
8
  describe 'For the email validation endpoint', order: :defined, vcr: vcr_opts do
9
9
  before(:all) do
10
- @mg_obj = Mailgun::Address.new(PUB_APIKEY)
10
+ @mg_obj = Mailgun::Address.new
11
11
 
12
12
  @valid = ["Alice <alice@example.com>", "bob@example.com"]
13
13
  @invalid = ["example.org"]
@@ -15,13 +15,6 @@ describe 'For the email validation endpoint', order: :defined, vcr: vcr_opts do
15
15
  @all_addrs = @valid + @invalid
16
16
  end
17
17
 
18
- it 'returns parsed and unparsable lists' do
19
- res = @mg_obj.parse(@all_addrs)
20
-
21
- expect(res["parsed"]).to eq(@valid)
22
- expect(res["unparseable"]).to eq(@invalid)
23
- end
24
-
25
18
  it 'validates alice@mailgun.net with info' do
26
19
  res = @mg_obj.validate("alice@mailgun.net")
27
20
 
@@ -34,6 +34,78 @@ describe 'Client exceptions', vcr: vcr_opts do
34
34
  end
35
35
  end
36
36
 
37
+ vcr_opts = { :cassette_name => "exceptions-invalid-api-key" }
38
+
39
+ describe 'Client exceptions', vcr: vcr_opts do
40
+ before(:all) do
41
+ @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
42
+ @domain = TESTDOMAIN
43
+ end
44
+
45
+ it 'displays error information that API key is invalid' do
46
+ begin
47
+ @mg_obj.send_message(@domain, {
48
+ :from => "sally@#{@domain}",
49
+ :to => "sally@#{@domain}",
50
+ :subject => 'Exception Integration Test',
51
+ :text => 'INTEGRATION TESTING'
52
+ })
53
+ rescue Mailgun::Unauthorized => err
54
+ expect(err.message).to eq('401 Unauthorized - Invalid Domain or API key: Forbidden')
55
+ else
56
+ fail
57
+ end
58
+ end
59
+ end
60
+
61
+ vcr_opts = { :cassette_name => "exceptions-invalid-data" }
62
+
63
+ describe 'Client exceptions', vcr: vcr_opts do
64
+ before(:all) do
65
+ @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
66
+ @domain = TESTDOMAIN
67
+ end
68
+
69
+ it 'display useful error information' do
70
+ begin
71
+ @mg_obj.send_message(@domain, {
72
+ :from => "sally@#{@domain}",
73
+ :to => "sally#{@domain}",
74
+ :subject => 'Exception Integration Test',
75
+ :text => 'INTEGRATION TESTING'
76
+ })
77
+ rescue Mailgun::BadRequest => err
78
+ expect(err.message).to eq('400 Bad Request: to parameter is not a valid address. please check documentation')
79
+ else
80
+ fail
81
+ end
82
+ end
83
+ end
84
+
85
+ vcr_opts = { :cassette_name => "exceptions-not-allowed" }
86
+
87
+ describe 'Client exceptions', vcr: vcr_opts do
88
+ before(:all) do
89
+ @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
90
+ @domain = TESTDOMAIN
91
+ end
92
+
93
+ it 'display useful error information' do
94
+ begin
95
+ @mg_obj.send_message(@domain, {
96
+ :from => "invalid@#{@domain}",
97
+ :to => "invalid#{@domain}",
98
+ :subject => 'Exception Integration Test',
99
+ :text => 'INTEGRATION TESTING'
100
+ })
101
+ rescue Mailgun::CommunicationError => err
102
+ expect(err.message).to include('403 Forbidden')
103
+ else
104
+ fail
105
+ end
106
+ end
107
+ end
108
+
37
109
  vcr_opts = { :cassette_name => "send_message" }
38
110
 
39
111
  describe 'The method send_message()', vcr: vcr_opts do
@@ -46,7 +46,8 @@ module Mailgun
46
46
  Mailgun::Response.new(response_generator(@endpoint))
47
47
  rescue => e
48
48
  p e
49
- raise CommunicationError.new(e), e.response
49
+ raise CommunicationError.new(e), e.response if e.respond_to? :response
50
+ raise CommunicationError.new(e.message)
50
51
  end
51
52
  end
52
53
 
@@ -87,6 +87,25 @@ describe 'The method post()' do
87
87
  expect(result.body).to include("message")
88
88
  expect(result.body).to include("id")
89
89
  end
90
+
91
+ context 'when Unknown API error is raised' do
92
+ before do
93
+ allow(Mailgun::Response).to receive(:new).and_raise(StandardError, "message")
94
+ allow(JSON).to receive(:parse).and_raise('Unknown')
95
+ end
96
+
97
+ it 'adds Unknown API error to message' do
98
+ data = {'from' => 'joe@test.com',
99
+ 'to' => 'bob@example.com',
100
+ 'subject' => 'Test',
101
+ 'text' => 'Test Data'}
102
+ @mg_obj.post("#{@domain}/messages", data)
103
+ rescue Mailgun::CommunicationError => err
104
+ expect(err.message).to eq('message: Unknown API error')
105
+ else
106
+ fail
107
+ end
108
+ end
90
109
  end
91
110
 
92
111
  describe 'The method put()' do
@@ -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-email%40DOMAIN.TEST&code=550&error=Integration%20Test
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-email@DOMAIN.TEST","message":"Address
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-email@DOMAIN.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-email@DOMAIN.TEST","code":"550","error":"Integration
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-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-email%40DOMAIN.TEST\u0026limit=100","previous":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=previous\u0026address=integration-test-email%40DOMAIN.TEST\u0026limit=100"}}'
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-email@DOMAIN.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-email@DOMAIN.TEST","message":"Bounced
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
@@ -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
- recorded_with: VCR 3.0.1
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