1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionmailbox/lib/action_mailbox/mail_ext/addresses.rb
2018-12-26 16:18:42 -05:00

29 lines
634 B
Ruby

# frozen_string_literal: true
module Mail
class Message
def from_address
header[:from]&.address_list&.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)
end
def cc_addresses
Array(header[:cc]&.address_list&.addresses)
end
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
end