Skip to content

Commit

Permalink
Merge pull request #46643 from ghiculescu/mail-28
Browse files Browse the repository at this point in the history
Fix CI for Mail 2.8+
  • Loading branch information
byroot committed Dec 5, 2022
1 parent 534256b commit f5463f3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions actionmailbox/lib/action_mailbox/mail_ext/addresses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,38 @@
module Mail
class Message
def from_address
header[:from]&.address_list&.addresses&.first
address_list(header[:from])&.addresses&.first
end

def recipients_addresses
to_addresses + cc_addresses + bcc_addresses + x_original_to_addresses
end

def to_addresses
Array(header[:to]&.address_list&.addresses)
Array(address_list(header[:to])&.addresses)
end

def cc_addresses
Array(header[:cc]&.address_list&.addresses)
Array(address_list(header[:cc])&.addresses)
end

def bcc_addresses
Array(header[:bcc]&.address_list&.addresses)
Array(address_list(header[:bcc])&.addresses)
end

def x_original_to_addresses
Array(header[:x_original_to]).collect { |header| Mail::Address.new header.to_s }
end

private
def address_list(obj)
if obj&.respond_to?(:element)
# Mail 2.8+
obj.element
else
# Mail <= 2.7.x
obj&.address_list
end
end
end
end

0 comments on commit f5463f3

Please sign in to comment.