mailtrap 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +19 -12
- data/Gemfile.lock +1 -1
- data/README.md +14 -0
- data/lib/mailtrap/sending/client.rb +17 -6
- data/lib/mailtrap/sending.rb +15 -0
- data/lib/mailtrap/version.rb +1 -1
- data/mailtrap.gemspec +30 -0
- metadata +3 -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/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,24 +1,31 @@
|
|
1
|
-
## [1.
|
1
|
+
## [1.2.2] - 2023-11-01
|
2
2
|
|
3
|
-
-
|
3
|
+
- Improved error handling
|
4
4
|
|
5
|
-
## [1.
|
5
|
+
## [1.2.1] - 2023-04-12
|
6
6
|
|
7
|
-
-
|
7
|
+
- Set custom user agent
|
8
|
+
|
9
|
+
## [1.2.0] - 2023-01-27
|
10
|
+
|
11
|
+
- Breaking changes:
|
12
|
+
- move `Mailtrap::Sending::Mail` class to `Mailtrap::Mail::Base`
|
13
|
+
- move `Mailtrap::Sending::Convert` to `Mailtrap::Mail`
|
14
|
+
- Add mail gem 2.8 support
|
15
|
+
- Add email template support
|
8
16
|
|
17
|
+
## [1.1.1] - 2022-10-14
|
18
|
+
|
19
|
+
- Fix custom port and host usage
|
9
20
|
|
10
21
|
## [1.1.0] - 2022-07-22
|
11
22
|
|
12
23
|
- Add ActionMailer support
|
13
24
|
|
14
|
-
## [1.
|
25
|
+
## [1.0.1] - 2022-06-20
|
15
26
|
|
16
|
-
-
|
27
|
+
- Update packed files list
|
17
28
|
|
18
|
-
## [1.
|
29
|
+
## [1.0.0] - 2022-06-14
|
19
30
|
|
20
|
-
-
|
21
|
-
- move `Mailtrap::Sending::Mail` class to `Mailtrap::Mail::Base`
|
22
|
-
- move `Mailtrap::Sending::Convert` to `Mailtrap::Mail`
|
23
|
-
- Add mail gem 2.8 support
|
24
|
-
- Add email template support
|
31
|
+
- Initial release
|
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.
|
@@ -38,20 +38,31 @@ module Mailtrap
|
|
38
38
|
request.body = body
|
39
39
|
request['Authorization'] = "Bearer #{api_key}"
|
40
40
|
request['Content-Type'] = 'application/json'
|
41
|
+
request['User-Agent'] = 'mailtrap-ruby (https://github.com/railsware/mailtrap-ruby)'
|
41
42
|
|
42
43
|
request
|
43
44
|
end
|
44
45
|
|
45
|
-
def handle_response(response)
|
46
|
-
case response
|
47
|
-
when
|
46
|
+
def handle_response(response) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
47
|
+
case response
|
48
|
+
when Net::HTTPOK
|
48
49
|
json_response(response.body)
|
49
|
-
when
|
50
|
+
when Net::HTTPBadRequest
|
50
51
|
raise Mailtrap::Sending::Error, json_response(response.body)[:errors]
|
51
|
-
when
|
52
|
+
when Net::HTTPUnauthorized
|
52
53
|
raise Mailtrap::Sending::AuthorizationError, json_response(response.body)[:errors]
|
53
|
-
|
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
|
54
63
|
raise Mailtrap::Sending::Error, ['server error']
|
64
|
+
else
|
65
|
+
raise Mailtrap::Sending::Error, ["unexpected status code=#{response.code}"]
|
55
66
|
end
|
56
67
|
end
|
57
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
data/mailtrap.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/mailtrap/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'mailtrap'
|
7
|
+
spec.version = Mailtrap::VERSION
|
8
|
+
spec.authors = ['Railsware Products Studio LLC']
|
9
|
+
spec.email = ['support@mailtrap.io']
|
10
|
+
|
11
|
+
spec.summary = 'Official mailtrap.io API client'
|
12
|
+
spec.description = 'Official mailtrap.io API client'
|
13
|
+
spec.homepage = 'https://github.com/railsware/mailtrap-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.7.0'
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/railsware/mailtrap-ruby'
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/railsware/mailtrap-ruby/blob/main/CHANGELOG.md'
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|github|travis|circleci)|appveyor)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
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.
|
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:
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/mailtrap/sending/attachment.rb
|
40
40
|
- lib/mailtrap/sending/client.rb
|
41
41
|
- lib/mailtrap/version.rb
|
42
|
+
- mailtrap.gemspec
|
42
43
|
homepage: https://github.com/railsware/mailtrap-ruby
|
43
44
|
licenses:
|
44
45
|
- MIT
|