Sha256: 66a0611d9c2f4c4fe7ae6875673e0a84c6b37d2a45522a5a4c8ab6917883b33f

Contents?: true

Size: 752 Bytes

Versions: 3

Compression:

Stored size: 752 Bytes

Contents

require 'pop_ssl'

module MList
  module EmailServer
    
    class Pop < Base
      def deliver(tmail, destinations)
        raise "Mail cannot be delivered through a POP server. Please use the '#{MList::EmailServer::Default.name}' type."
      end
      
      def execute
        connect_to_email_account do |pop|
          pop.mails.each { |message| receive(TMail::Mail.parse(message.pop)); message.delete }
        end
      end
      
      private
        def connect_to_email_account
          pop3 = Net::POP3.new(settings[:server], settings[:port], false)
          pop3.enable_ssl if settings[:ssl]
          pop3.start(settings[:username], settings[:password]) do |pop|
            yield pop
          end
        end
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aiwilliams-mlist-0.1.0 lib/mlist/email_server/pop.rb
aiwilliams-mlist-0.1.1 lib/mlist/email_server/pop.rb
aiwilliams-mlist-0.1.2 lib/mlist/email_server/pop.rb