Skip to content

Instantly share code, notes, and snippets.

@boblmartens
Created February 9, 2010 02:47
Show Gist options
  • Save boblmartens/298866 to your computer and use it in GitHub Desktop.
Save boblmartens/298866 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment