From a7cdfce574db7469a80f5381c198447d960b1acc Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 10 Nov 2025 11:18:26 +1000 Subject: [PATCH 1/2] Write the message IDs to the message on successful send --- Gemfile | 1 + Gemfile.lock | 2 ++ lib/mailtrap/action_mailer/delivery_method.rb | 4 +++- spec/mailtrap/action_mailer/delivery_method_spec.rb | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 75bb86b..9b8bc48 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ source 'https://rubygems.org' gemspec gem 'appraisal' +gem 'base64' gem 'mail' gem 'net-smtp' gem 'rake', '~> 13.0' diff --git a/Gemfile.lock b/Gemfile.lock index 37c0936..47d9fe5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,6 +13,7 @@ GEM rake thor (>= 0.14.0) ast (2.4.2) + base64 (0.3.0) bigdecimal (3.1.8) crack (1.0.0) bigdecimal @@ -95,6 +96,7 @@ PLATFORMS DEPENDENCIES appraisal + base64 mail mailtrap! net-smtp diff --git a/lib/mailtrap/action_mailer/delivery_method.rb b/lib/mailtrap/action_mailer/delivery_method.rb index 6fa3bd5..f0c0929 100644 --- a/lib/mailtrap/action_mailer/delivery_method.rb +++ b/lib/mailtrap/action_mailer/delivery_method.rb @@ -14,7 +14,9 @@ def initialize(settings) def deliver!(message) mail = Mailtrap::Mail.from_message(message) - client.send(mail) + client.send(mail).tap do |resp| + message['X-MT-Message-IDs'] = resp[:message_ids] + end end private diff --git a/spec/mailtrap/action_mailer/delivery_method_spec.rb b/spec/mailtrap/action_mailer/delivery_method_spec.rb index a88784f..f444667 100644 --- a/spec/mailtrap/action_mailer/delivery_method_spec.rb +++ b/spec/mailtrap/action_mailer/delivery_method_spec.rb @@ -48,6 +48,7 @@ it 'converts the message and sends via API' do expect(deliver!).to eq({ success: true, message_ids: expected_message_ids }) + expect(message['X-MT-Message-IDs'].to_s).to eq(expected_message_ids.join(', ')) expect(Mailtrap::Client).to have_received(:new).with(api_key: 'correct-api-key') end end From ccd38a99e9b6955b6197be34d84e11d87694737d Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 10 Nov 2025 11:23:41 +1000 Subject: [PATCH 2/2] no changes --- Gemfile.lock | 57 ++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 01d507c..68bfdbd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,29 +13,30 @@ GEM bundler rake thor (>= 0.14.0) - ast (2.4.2) + ast (2.4.3) base64 (0.3.0) bigdecimal (3.1.8) crack (1.0.0) bigdecimal rexml - date (3.3.4) + date (3.4.1) diff-lcs (1.5.1) hashdiff (1.1.0) - io-console (0.8.1) - irb (1.15.3) + io-console (0.8.0) + irb (1.15.2) pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.7.2) - language_server-protocol (3.17.0.3) + json (2.12.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) mail (2.8.1) mini_mime (>= 0.1.1) net-imap net-pop net-smtp mini_mime (1.1.5) - net-imap (0.4.14) + net-imap (0.5.7) date net-protocol net-pop (0.1.2) @@ -44,26 +45,27 @@ GEM timeout net-smtp (0.5.0) net-protocol - parallel (1.25.1) - parser (3.3.3.0) + parallel (1.27.0) + parser (3.3.8.0) ast (~> 2.4.1) racc - pp (0.6.3) + pp (0.6.2) prettyprint prettyprint (0.2.0) + prism (1.4.0) psych (5.2.6) date stringio public_suffix (5.1.1) - racc (1.8.0) + racc (1.8.1) rainbow (3.1.1) rake (13.2.1) rdoc (6.13.1) psych (>= 4.0.0) - regexp_parser (2.9.2) - reline (0.6.2) + regexp_parser (2.10.0) + reline (0.6.1) io-console (~> 0.5) - rexml (3.3.9) + rexml (3.4.2) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -80,28 +82,31 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - rubocop (1.64.1) + rubocop (1.78.0) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.45.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) - parser (>= 3.3.1.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.45.1) + parser (>= 3.3.7.2) + prism (~> 1.4) rubocop-rake (0.6.0) rubocop (~> 1.0) rubocop-rspec (3.0.2) rubocop (~> 1.61) ruby-progressbar (1.13.0) stringio (3.1.7) - thor (1.3.1) - timeout (0.4.1) - unicode-display_width (2.5.0) + thor (1.4.0) + timeout (0.4.3) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) vcr (6.2.0) webmock (3.23.1) addressable (>= 2.8.0) @@ -130,4 +135,4 @@ DEPENDENCIES yard (~> 0.9) BUNDLED WITH - 2.5.14 + 2.6.5