Sha256: 8767b01c4d3bc08572b02d9ff6f1295db60f5d95aa89a95443b3aa06b070980a

Contents?: true

Size: 1003 Bytes

Versions: 18

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

module Mail
  class Message
    def from_address
      address_list(header[:from])&.addresses&.first
    end

    def recipients_addresses
      to_addresses + cc_addresses + bcc_addresses + x_original_to_addresses + x_forwarded_to_addresses
    end

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

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

    def bcc_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

    def x_forwarded_to_addresses
      Array(header[:x_forwarded_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

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/actionmailbox-7.1.3.4/lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.5.1 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.5 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.4.2 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.4.1 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.4 lib/action_mailbox/mail_ext/addresses.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actionmailbox-7.1.3.4/lib/action_mailbox/mail_ext/addresses.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/actionmailbox-7.1.3.4/lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.3.4 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.3.2 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.3.1 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.3 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.2 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.1 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.0 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.0.rc2 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.0.rc1 lib/action_mailbox/mail_ext/addresses.rb
actionmailbox-7.1.0.beta1 lib/action_mailbox/mail_ext/addresses.rb