aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-11-13 17:44:31 -0500
committerGeorge Claghorn <george@basecamp.com>2018-11-13 17:48:48 -0500
commitdd43f6e7d90ab0d2c354a9bef1970e4f3a7e6471 (patch)
treeba434e5cefa3ac21b935cf7b80ac6f540cdfbe67
parent14b5b5afe2bf7369499243931a88db5f40933def (diff)
downloadrails-dd43f6e7d90ab0d2c354a9bef1970e4f3a7e6471.tar.gz
rails-dd43f6e7d90ab0d2c354a9bef1970e4f3a7e6471.tar.bz2
rails-dd43f6e7d90ab0d2c354a9bef1970e4f3a7e6471.zip
Consider X-Original-To
-rw-r--r--lib/action_mailbox/mail_ext/addresses.rb6
-rw-r--r--lib/action_mailbox/mail_ext/recipients.rb2
-rw-r--r--test/unit/mail_ext/recipients_test.rb12
3 files changed, 14 insertions, 6 deletions
diff --git a/lib/action_mailbox/mail_ext/addresses.rb b/lib/action_mailbox/mail_ext/addresses.rb
index 8059ce0027..f64c3ef5df 100644
--- a/lib/action_mailbox/mail_ext/addresses.rb
+++ b/lib/action_mailbox/mail_ext/addresses.rb
@@ -4,7 +4,7 @@ class Mail::Message
end
def recipients_addresses
- to_addresses + cc_addresses + bcc_addresses
+ to_addresses + cc_addresses + bcc_addresses + x_original_to_addresses
end
def to_addresses
@@ -18,4 +18,8 @@ class Mail::Message
def bcc_addresses
Array(header[:bcc]&.address_list&.addresses)
end
+
+ def x_original_to_addresses
+ Array(header[:x_original_to]).collect { |header| Mail::Address.new header.to_s }
+ end
end
diff --git a/lib/action_mailbox/mail_ext/recipients.rb b/lib/action_mailbox/mail_ext/recipients.rb
index 58561c7f01..87255ce6ce 100644
--- a/lib/action_mailbox/mail_ext/recipients.rb
+++ b/lib/action_mailbox/mail_ext/recipients.rb
@@ -1,5 +1,5 @@
class Mail::Message
def recipients
- Array(to) + Array(cc) + Array(bcc)
+ Array(to) + Array(cc) + Array(bcc) + Array(header[:x_original_to]).map(&:to_s)
end
end
diff --git a/test/unit/mail_ext/recipients_test.rb b/test/unit/mail_ext/recipients_test.rb
index 86db569a53..e39e1eb89c 100644
--- a/test/unit/mail_ext/recipients_test.rb
+++ b/test/unit/mail_ext/recipients_test.rb
@@ -3,11 +3,15 @@ require_relative '../../test_helper'
module MailExt
class RecipientsTest < ActiveSupport::TestCase
setup do
- @mail = Mail.new(to: "david@basecamp.com", cc: "jason@basecamp.com", bcc: "andrea@basecamp.com")
+ @mail = Mail.new \
+ to: "david@basecamp.com",
+ cc: "jason@basecamp.com",
+ bcc: "andrea@basecamp.com",
+ x_original_to: "ryan@basecamp.com"
end
- test "recipients include everyone from to, cc, and bcc" do
- assert_equal %w[ david@basecamp.com jason@basecamp.com andrea@basecamp.com ], @mail.recipients
+ test "recipients include everyone from to, cc, bcc, and x-original-to" do
+ assert_equal %w[ david@basecamp.com jason@basecamp.com andrea@basecamp.com ryan@basecamp.com ], @mail.recipients
end
test "recipients addresses use address objects" do
@@ -26,4 +30,4 @@ module MailExt
assert_equal "basecamp.com", @mail.bcc_addresses.first.domain
end
end
-end \ No newline at end of file
+end