Sha256: 7fbe58723455d885b073c4f5f0406b97a19105fec5e1e2b87a1e41e1a8538ad5

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

module MList
  module EmailServer
    
    # The interface to an incoming email.
    #
    # My primary goal is to decouple the MList::EmailServer from the
    # MList::Server, this class acting as the bridge.
    #
    class Email
      
      # TODO Provide the email_server to the instances
      def initialize(tmail)
        @tmail = tmail
      end
      
      def from_address
        @tmail.from.first
      end
      
      # Answers the usable destination addresses of the email.
      #
      # TODO: Provide intelligence to this that allows it to ignore addresses
      # that are not for the domain of the email_server.
      #
      def list_addresses
        bounce? ? @tmail.header_string('to').match(/\Amlist-(.*)\Z/)[1] : @tmail.to
      end
      
      # Answers true if this email is a bounce.
      #
      # TODO Delegate to the email_server's bounce detector.
      #
      def bounce?
        @tmail.header_string('to') =~ /mlist-/
      end
      
      # Answers unique copies of the underlying TMail::Mail instance,
      # providing assurance that the MList::Server and it's sub-systems don't
      # stomp all over each other by getting a reference to a single
      # TMail::Mail instance.
      #
      def tmail
        TMail::Mail.parse(@tmail.to_s)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aiwilliams-mlist-0.0.0 lib/mlist/email_server/email.rb