mailtrap 1.2.1 → 1.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +14 -0
- data/lib/mailtrap/sending/client.rb +16 -6
- data/lib/mailtrap/sending.rb +15 -0
- data/lib/mailtrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c02915dc1ea123fb592af56b9c553cb97e6137f0555b98f965f3a8cf1dd1d229
|
4
|
+
data.tar.gz: 8e7da7be2313f3e3766512e5c4014f90d1f8f1ddb271cbd255494252b6eda161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962e1a2227a79b264bd637f643ffbf326c03d56ba1736a406869fda693eb67c5ffed3797cacd1862403e034ba543c44094829fe45ec36c6fcfa2e96ecdd554c3
|
7
|
+
data.tar.gz: b568ff9976cba7311ae02118bbbe5b825230743facd0094921fa3ac58d4fe4d8132c9b9bbc5dca4c6d60fc798fa18d8508149a871949de971e621af50c386177
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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
|
48
|
-
when
|
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
|
50
|
+
when Net::HTTPBadRequest
|
51
51
|
raise Mailtrap::Sending::Error, json_response(response.body)[:errors]
|
52
|
-
when
|
52
|
+
when Net::HTTPUnauthorized
|
53
53
|
raise Mailtrap::Sending::AuthorizationError, json_response(response.body)[:errors]
|
54
|
-
|
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
|
|
data/lib/mailtrap/sending.rb
CHANGED
@@ -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
|
data/lib/mailtrap/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Official mailtrap.io API client
|
14
14
|
email:
|