Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'net/imap'
- require 'pp'
- require 'yaml'
- conf = File.open( 'config.yaml' ) { |yf| YAML::load( yf ) }
- #custom verification callback used here only for debugging
- VerifyCallbackProc = proc do |v, ctx|
- #p ctx.methods
- #p v, ctx.current_cert, ctx.chain
- v
- end
- imap_host = conf[:imap_host]
- imap_user = conf[:imap_user]
- imap_pass = conf[:imap_pass]
- ca_file = conf[:ca_file]
- imap_ssl = {:ca_file=>ca_file}
- #skip verification for now
- imap_ssl = {:verify_mode=>0}
- mbox = Net::IMAP.new(imap_host, {:ssl=>imap_ssl})
- mbox.login(imap_user, imap_pass)
- #p mbox.list("","*")
- mbox.select('INBOX')
- mbox.search(['ALL']).each do |msgid|
- data = mbox.fetch(msgid, "(BODY[TEXT])")[0].attr['BODY[TEXT]']
- p data
- end
- mbox.close
- mbox.logout
- mbox.disconnect
Add Comment
Please, Sign In to add comment