Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'net/imap'
- module Imapper
- class Session
- def initialize(email_address, passwd)
- @imap = Net::IMAP.new('imap.gmail.com', 993, true, nil, false)
- @imap.login(email_address, passwd)
- end
- def inbox
- @imap.examine('INBOX')
- @imap.search(["SINCE", "6-Nov-2009"]).collect do |message_id|
- @imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
- end
- end
- end
- end
- print "Enter email address: "
- email_addr = gets.chomp
- print "Enter password: "
- passwd = gets.chomp
- session = Imapper::Session.new(email_addr, passwd)
- messages = session.inbox
- messages.each do |message|
- puts message.subject
- end
Add Comment
Please, Sign In to add comment