mailtrap 2.1.1 → 2.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30f80c3c771f5d73e22d3731d3f8d619793be03b378f48251e0e17e0e33d5d60
4
- data.tar.gz: 41523de1f211b8ef4900efe6abd2343afb67803921fe495372c1d780d5b0f6fa
3
+ metadata.gz: 1196fd7757c7db95173f2c040fda8ef50df5c9091f58a29c9797fcacf9245826
4
+ data.tar.gz: 2e45581913e2f8d0de7c0b849e1492fa897cafe2aa1a617aa9bd58874a02f60a
5
5
  SHA512:
6
- metadata.gz: 781f8682fec57e56274d6de148bf24cc2d21ae8582e31a00585eaceb15481cf8b8508f9f1ba7f32b54e71c3c18b5062a6f2be407f5e14df0b78b5038a1086e9e
7
- data.tar.gz: 1f22fc8e1c76efb7e0050d68b731ea0ceba6a65a8d37cea1da72369d41287f657492e005683648b1b7279e15e059f6c14a4ec724015763f2d212bde1407dd097
6
+ metadata.gz: dac2ad6b21f7e0cf6dba74399e41060eeb24d207bd70013b557d0e149c3857cb9befd294cae2a5795cf9174c5641e0382dd48aa00188e1e1666045625a63aa43
7
+ data.tar.gz: 023babe084f759890ab8b40b5d57a458f538ee85e3dc28baab384536bd49ff8f5ca60c84bf8ca494529a97b2b064f5f937487568023a6ccc1787a46497b77b77
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
+ ## [2.2.0] - 2024-12-18
2
+
3
+ - Added `reply_to` parameter support
4
+
5
+ ## [2.1.2] - 2024-12-13
6
+
7
+ - Improved handling of invalid `from`, `to`, `cc`, `bcc` headers when sending
8
+ with Action Mailer
9
+
1
10
  ## [2.1.1] - 2024-12-11
2
11
 
3
- - Improved handling of empty `from`
12
+ - Improved handling of empty `from` header when sending with Action Mailer
4
13
 
5
14
  ## [2.1.0] - 2024-07-08
6
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mailtrap (2.1.1)
4
+ mailtrap (2.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -52,6 +52,7 @@ mail = Mailtrap::Mail::Base.new(
52
52
  to: [
53
53
  { email: 'your@email.com' }
54
54
  ],
55
+ reply_to: { email: 'support@example.com', name: 'Mailtrap Reply-To' },
55
56
  subject: 'You are awesome!',
56
57
  text: "Congrats for sending test email with Mailtrap!"
57
58
  )
@@ -5,12 +5,13 @@ require 'json'
5
5
  module Mailtrap
6
6
  module Mail
7
7
  class Base
8
- attr_accessor :from, :to, :cc, :bcc, :headers, :custom_variables, :subject, :text, :html, :category
8
+ attr_accessor :from, :to, :reply_to, :cc, :bcc, :headers, :custom_variables, :subject, :text, :html, :category
9
9
  attr_reader :attachments
10
10
 
11
11
  def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
12
12
  from: nil,
13
13
  to: [],
14
+ reply_to: nil,
14
15
  cc: [],
15
16
  bcc: [],
16
17
  subject: nil,
@@ -23,6 +24,7 @@ module Mailtrap
23
24
  )
24
25
  @from = from
25
26
  @to = to
27
+ @reply_to = reply_to
26
28
  @cc = cc
27
29
  @bcc = bcc
28
30
  @subject = subject
@@ -38,6 +40,7 @@ module Mailtrap
38
40
  {
39
41
  'from' => from,
40
42
  'to' => to,
43
+ 'reply_to' => reply_to,
41
44
  'cc' => cc,
42
45
  'bcc' => bcc,
43
46
  'subject' => subject,
@@ -8,6 +8,7 @@ module Mailtrap
8
8
  def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
9
9
  from: nil,
10
10
  to: [],
11
+ reply_to: nil,
11
12
  cc: [],
12
13
  bcc: [],
13
14
  attachments: [],
@@ -19,6 +20,7 @@ module Mailtrap
19
20
  super(
20
21
  from: from,
21
22
  to: to,
23
+ reply_to: reply_to,
22
24
  cc: cc,
23
25
  bcc: bcc,
24
26
  attachments: attachments,
data/lib/mailtrap/mail.rb CHANGED
@@ -4,10 +4,13 @@ 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
12
+ # @param message [Mail::Message]
13
+ # @return [Mailtrap::Mail::Base]
11
14
  def from_message(message) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
12
15
  Mailtrap::Mail::Base.new(
13
16
  from: prepare_addresses(address_list(message['from'])&.addresses).first,
@@ -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
- header.respond_to?(:element) ? header.element : header&.address_list
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,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailtrap
4
- VERSION = '2.1.1'
4
+ VERSION = '2.2.0'
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: 2.1.1
4
+ version: 2.2.0
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-12-11 00:00:00.000000000 Z
11
+ date: 2024-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Official mailtrap.io API client
14
14
  email:
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  requirements: []
65
- rubygems_version: 3.4.10
65
+ rubygems_version: 3.5.11
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Official mailtrap.io API client