mailtrap 1.2.1 → 1.2.2

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
  SHA256:
3
- metadata.gz: 7dee4a202b02e16f840e8fc74526903e10418a0073c2392faf964dcdbcdfcde4
4
- data.tar.gz: d35cf9fa125e8ec587f96626be7830f4398002173b7dc07c4560dddbbb0ddb3e
3
+ metadata.gz: c02915dc1ea123fb592af56b9c553cb97e6137f0555b98f965f3a8cf1dd1d229
4
+ data.tar.gz: 8e7da7be2313f3e3766512e5c4014f90d1f8f1ddb271cbd255494252b6eda161
5
5
  SHA512:
6
- metadata.gz: 5b4c0ba57ab2cab64cec15704bd34c04be134360a2600d2fc530bcae47ab8caf2e8dd79ce7ba5fd342e46dad599153d473006613c953da868182dcff2bb1e2be
7
- data.tar.gz: 45d64a548b0cd54e0f98394a8c6739d1bc5dcd90716105100f7bae92f7aa5913c9ff66fde412d8965d3818bc7d6594c1c218d96cfcde59eabc6bd92c1901e2c3
6
+ metadata.gz: 962e1a2227a79b264bd637f643ffbf326c03d56ba1736a406869fda693eb67c5ffed3797cacd1862403e034ba543c44094829fe45ec36c6fcfa2e96ecdd554c3
7
+ data.tar.gz: b568ff9976cba7311ae02118bbbe5b825230743facd0094921fa3ac58d4fe4d8132c9b9bbc5dca4c6d60fc798fa18d8508149a871949de971e621af50c386177
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.2.2] - 2023-11-01
2
+
3
+ - Improved error handling
4
+
1
5
  ## [1.2.1] - 2023-04-12
2
6
 
3
7
  - Set custom user agent
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mailtrap (1.2.1)
4
+ mailtrap (1.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -130,6 +130,20 @@ mail(
130
130
  )
131
131
  ```
132
132
 
133
+ #### Content-Transfer-Encoding
134
+
135
+ `mailtrap` gem uses Mailtrap API to send emails. Mailtrap API does not try to
136
+ replicate SMTP. That is why you should expect some limitations when it comes to
137
+ sending. For example, `/api/send` endpoint ignores `Content-Transfer-Encoding`
138
+ (see `headers` in the [API documentation](https://railsware.stoplight.io/docs/mailtrap-api-docs/67f1d70aeb62c-send-email)).
139
+ Meaning your recipients will receive emails only in the default encoding which
140
+ is `quoted-printable`, if you send with Mailtrap API.
141
+
142
+ For those who does need to use `7bit` or any other encoding, SMTP provides
143
+ better flexibility in that regard. Go to your _Mailtrap account_ → _Email Sending_
144
+ → _Sending Domains_ → _Your domain_ → _SMTP/API Settings_ to find the SMTP
145
+ configuration example.
146
+
133
147
  ## Development
134
148
 
135
149
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -43,16 +43,26 @@ module Mailtrap
43
43
  request
44
44
  end
45
45
 
46
- def handle_response(response)
47
- case response.code
48
- when '200'
46
+ def handle_response(response) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
47
+ case response
48
+ when Net::HTTPOK
49
49
  json_response(response.body)
50
- when '400'
50
+ when Net::HTTPBadRequest
51
51
  raise Mailtrap::Sending::Error, json_response(response.body)[:errors]
52
- when '401'
52
+ when Net::HTTPUnauthorized
53
53
  raise Mailtrap::Sending::AuthorizationError, json_response(response.body)[:errors]
54
- else
54
+ when Net::HTTPForbidden
55
+ raise Mailtrap::Sending::RejectionError, json_response(response.body)[:errors]
56
+ when Net::HTTPPayloadTooLarge
57
+ raise Mailtrap::Sending::MailSizeError, ['message too large']
58
+ when Net::HTTPTooManyRequests
59
+ raise Mailtrap::Sending::RateLimitError, ['too many requests']
60
+ when Net::HTTPClientError
61
+ raise Mailtrap::Sending::Error, ['client error']
62
+ when Net::HTTPServerError
55
63
  raise Mailtrap::Sending::Error, ['server error']
64
+ else
65
+ raise Mailtrap::Sending::Error, ["unexpected status code=#{response.code}"]
56
66
  end
57
67
  end
58
68
 
@@ -17,6 +17,21 @@ module Mailtrap
17
17
  end
18
18
  end
19
19
 
20
+ # AuthorizationError is raised when invalid token is used.
20
21
  class AuthorizationError < Error; end
22
+
23
+ # MailSizeError is raised when mail is too large.
24
+ class MailSizeError < Error; end
25
+
26
+ # RateLimitError is raised when client performing too many requests.
27
+ class RateLimitError < Error; end
28
+
29
+ # RejectionError is raised when server refuses to process the request. Use
30
+ # error message to debug the problem.
31
+ #
32
+ # *Some* possible reasons:
33
+ # * Account is banned
34
+ # * Domain is not verified
35
+ class RejectionError < Error; end
21
36
  end
22
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailtrap
4
- VERSION = '1.2.1'
4
+ VERSION = '1.2.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailtrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Railsware Products Studio LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-13 00:00:00.000000000 Z
11
+ date: 2023-11-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Official mailtrap.io API client
14
14
  email: