Sha256: d6740d2d14eed42006966633dec0fe0bf966c628253fbe9e09ee63baa5ca8cf2
Contents?: true
Size: 890 Bytes
Versions: 1
Compression:
Stored size: 890 Bytes
Contents
module Mail class IMAP require 'net/imap' def initialize(values) self.settings = { :address => "localhost", :port => 110, :user_name => nil, :password => nil, :authentication => nil, :enable_ssl => false }.merge!(values) end attr_accessor :settings def first(options = {}, &block) imap = Net::IMAP.new(settings[:address], settings[:port], settings[:enable_ssl]) imap.login(settings[:user_name], settings[:password]) imap.examine('INBOX') uids = imap.uid_search('ALL') uids = uids[0,options[:count]] if options[:count] uids.each do |message_id| fetch_data = imap.uid_fetch(message_id, ['BODY.PEEK[HEADER]']) fetch_data.each{|fd| yield Mail.new(fd.attr['BODY[HEADER]'])} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kbaum-mail-2.1.2.1 | lib/mail/network/retriever_methods/imap.rb |