mailtrap 2.1.0 → 2.1.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 +9 -0
- data/Gemfile.lock +2 -4
- data/README.md +22 -7
- data/lib/mailtrap/mail.rb +16 -3
- data/lib/mailtrap/version.rb +1 -1
- metadata +2 -3
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 314cfc7c3cd8a6e45f719fc3d8063a5ca9d9cb96109989d558699460c5246735
|
4
|
+
data.tar.gz: 6db332cea7a1c9e8409c22a47145b74b9a5a45d74cc34a3663bc138fd7bf52a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d86a290cd93fea1c62a5bf5c5ee1d32a49bf23bd9736edf1d4cffe5d1c40d474b62cda3741deb388ff24e937eb036ce618605155f5b7e66f4a95918d400315e
|
7
|
+
data.tar.gz: 51548a285463a11ef0c408f9cb03d2621bb0ede07c75c63773218a85616fcd727724b15687389350fdaf4907f6c173a95fee1d17d4648c5f0d315817acf7bbec
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [2.1.2] - 2024-12-13
|
2
|
+
|
3
|
+
- Improved handling of invalid `from`, `to`, `cc`, `bcc` headers when sending
|
4
|
+
with Action Mailer
|
5
|
+
|
6
|
+
## [2.1.1] - 2024-12-11
|
7
|
+
|
8
|
+
- Improved handling of empty `from` header when sending with Action Mailer
|
9
|
+
|
1
10
|
## [2.1.0] - 2024-07-08
|
2
11
|
|
3
12
|
- Fixed extraneous headers added by ActionMailer #21
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mailtrap (2.1.
|
4
|
+
mailtrap (2.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -46,8 +46,7 @@ GEM
|
|
46
46
|
rainbow (3.1.1)
|
47
47
|
rake (13.2.1)
|
48
48
|
regexp_parser (2.9.2)
|
49
|
-
rexml (3.3.
|
50
|
-
strscan
|
49
|
+
rexml (3.3.9)
|
51
50
|
rspec (3.13.0)
|
52
51
|
rspec-core (~> 3.13.0)
|
53
52
|
rspec-expectations (~> 3.13.0)
|
@@ -82,7 +81,6 @@ GEM
|
|
82
81
|
rubocop-rspec (3.0.2)
|
83
82
|
rubocop (~> 1.61)
|
84
83
|
ruby-progressbar (1.13.0)
|
85
|
-
strscan (3.1.0)
|
86
84
|
thor (1.3.1)
|
87
85
|
timeout (0.4.1)
|
88
86
|
unicode-display_width (2.5.0)
|
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
[](https://github.com/railsware/mailtrap-ruby/actions/workflows/main.yml)
|
2
|
+
[](https://rubydoc.info/gems/mailtrap)
|
3
|
+
[](https://rubygems.org/gems/mailtrap)
|
4
|
+
[](https://rubygems.org/gems/mailtrap)
|
5
|
+
|
6
|
+
|
2
7
|
|
3
8
|
# Official Mailtrap Ruby client
|
4
9
|
|
@@ -26,7 +31,17 @@ Or install it yourself as:
|
|
26
31
|
|
27
32
|
## Usage
|
28
33
|
|
29
|
-
###
|
34
|
+
### Ruby on Rails
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
# place this code in config/environments/production.rb:
|
38
|
+
config.action_mailer.delivery_method = :mailtrap
|
39
|
+
|
40
|
+
# then set the MAILTRAP_API_KEY environment variable
|
41
|
+
# using your hosting solution.
|
42
|
+
```
|
43
|
+
|
44
|
+
### Pure Ruby
|
30
45
|
|
31
46
|
```ruby
|
32
47
|
require 'mailtrap'
|
@@ -46,7 +61,7 @@ client = Mailtrap::Client.new(api_key: 'your-api-key')
|
|
46
61
|
client.send(mail)
|
47
62
|
```
|
48
63
|
|
49
|
-
Refer to the [`examples`](examples) folder for
|
64
|
+
Refer to the [`examples`](examples) folder for more examples.
|
50
65
|
|
51
66
|
- [Full](examples/full.rb)
|
52
67
|
- [Email template](examples/email_template.rb)
|
@@ -55,15 +70,15 @@ Refer to the [`examples`](examples) folder for other examples.
|
|
55
70
|
### Content-Transfer-Encoding
|
56
71
|
|
57
72
|
`mailtrap` gem uses Mailtrap API to send emails. Mailtrap API does not try to
|
58
|
-
replicate SMTP. That is why you should expect some limitations when it comes to
|
73
|
+
replicate SMTP. That is why you should expect some limitations when it comes to
|
59
74
|
sending. For example, `/api/send` endpoint ignores `Content-Transfer-Encoding`
|
60
75
|
(see `headers` in the [API documentation](https://railsware.stoplight.io/docs/mailtrap-api-docs/67f1d70aeb62c-send-email)).
|
61
|
-
Meaning your recipients will receive emails only in the default encoding which
|
76
|
+
Meaning your recipients will receive emails only in the default encoding which
|
62
77
|
is `quoted-printable`, if you send with Mailtrap API.
|
63
78
|
|
64
|
-
For those who does need to use `7bit` or any other encoding, SMTP provides
|
65
|
-
better flexibility in that regard. Go to your _Mailtrap account_ → _Email Sending_
|
66
|
-
→ _Sending Domains_ → _Your domain_ → _SMTP/API Settings_ to find the SMTP
|
79
|
+
For those who does need to use `7bit` or any other encoding, SMTP provides
|
80
|
+
better flexibility in that regard. Go to your _Mailtrap account_ → _Email Sending_
|
81
|
+
→ _Sending Domains_ → _Your domain_ → _SMTP/API Settings_ to find the SMTP
|
67
82
|
configuration example.
|
68
83
|
|
69
84
|
## Migration guide v1 → v2
|
data/lib/mailtrap/mail.rb
CHANGED
@@ -4,13 +4,16 @@ require 'base64'
|
|
4
4
|
|
5
5
|
require_relative 'mail/base'
|
6
6
|
require_relative 'mail/from_template'
|
7
|
+
require_relative 'errors'
|
7
8
|
|
8
9
|
module Mailtrap
|
9
10
|
module Mail
|
10
11
|
class << self
|
11
|
-
|
12
|
+
# @param message [Mail::Message]
|
13
|
+
# @return [Mailtrap::Mail::Base]
|
14
|
+
def from_message(message) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
12
15
|
Mailtrap::Mail::Base.new(
|
13
|
-
from:
|
16
|
+
from: prepare_addresses(address_list(message['from'])&.addresses).first,
|
14
17
|
to: prepare_addresses(address_list(message['to'])&.addresses),
|
15
18
|
cc: prepare_addresses(address_list(message['cc'])&.addresses),
|
16
19
|
bcc: prepare_addresses(address_list(message['bcc'])&.addresses),
|
@@ -50,10 +53,19 @@ module Mailtrap
|
|
50
53
|
|
51
54
|
HEADERS_TO_REMOVE = (SPECIAL_HEADERS + ACTIONMAILER_ADDED_HEADERS).freeze
|
52
55
|
|
56
|
+
# @param header [Mail::Field, nil]
|
57
|
+
# @return [Mail::AddressList, nil]
|
53
58
|
def address_list(header)
|
54
|
-
|
59
|
+
return nil unless header
|
60
|
+
|
61
|
+
unless header.errors.empty?
|
62
|
+
raise Mailtrap::Error, ["failed to parse '#{header.name}': '#{header.unparsed_value}'"]
|
63
|
+
end
|
64
|
+
|
65
|
+
header.respond_to?(:element) ? header.element : header.address_list
|
55
66
|
end
|
56
67
|
|
68
|
+
# @param addresses [Array<Mail::Address>, nil]
|
57
69
|
def prepare_addresses(addresses)
|
58
70
|
Array(addresses).map { |address| prepare_address(address) }
|
59
71
|
end
|
@@ -66,6 +78,7 @@ module Mailtrap
|
|
66
78
|
.compact
|
67
79
|
end
|
68
80
|
|
81
|
+
# @param address [Mail::Address]
|
69
82
|
def prepare_address(address)
|
70
83
|
{
|
71
84
|
email: address.address,
|
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: 2.1.
|
4
|
+
version: 2.1.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: 2024-
|
11
|
+
date: 2024-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Official mailtrap.io API client
|
14
14
|
email:
|
@@ -19,7 +19,6 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- ".rspec"
|
21
21
|
- ".rubocop.yml"
|
22
|
-
- ".ruby-version"
|
23
22
|
- Appraisals
|
24
23
|
- CHANGELOG.md
|
25
24
|
- CODE_OF_CONDUCT.md
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.3.3
|