Skip to content

Commit ac58320

Browse files
committed
Add reply_to_address Mail extension
Action Mailbox adds `*_address`/`*_addresses` methods to `Mail::Message` for from, to, cc, and bcc, but not for reply_to. This adds the missing extension for `reply_to_address`.
1 parent 85acb96 commit ac58320

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

actionmailbox/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
* Add `reply_to_address` extension method on `Mail::Message`.
2+
3+
*Mr0grog*
14

25
Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/actionmailbox/CHANGELOG.md) for previous changes.

actionmailbox/lib/action_mailbox/mail_ext/addresses.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ def from_address
66
address_list(header[:from])&.addresses&.first
77
end
88

9+
def reply_to_address
10+
address_list(header[:reply_to])&.addresses&.first
11+
end
12+
913
def recipients_addresses
1014
to_addresses + cc_addresses + bcc_addresses + x_original_to_addresses + x_forwarded_to_addresses
1115
end

actionmailbox/test/unit/mail_ext/addresses_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class AddressesTest < ActiveSupport::TestCase
77
setup do
88
@mail = Mail.new \
99
10+
reply_to: "[email protected]",
1011
1112
1213
@@ -18,6 +19,10 @@ class AddressesTest < ActiveSupport::TestCase
1819
assert_equal "example.com", @mail.from_address.domain
1920
end
2021

22+
test "reply to address uses address object" do
23+
assert_equal "example.com", @mail.reply_to_address.domain
24+
end
25+
2126
test "recipients include everyone from to, cc, bcc, x-original-to, and x-forwarded-to" do
2227
2328
end

0 commit comments

Comments
 (0)