Try Googling for the title of this post! A lot has been said about using Ruby to connect to your gmailbox. In short: with Ruby 1.8 you can’t. With Ruby 1.9 it’s broken. This post led me to the right path.
First thing to do is download a working version of the Ruby 1.9 POP3 library. The most recent version doesn’t work, so you need to grab an older one. This one. Download the file and save it as pop_ssl.rb.
Then you need this code to use it:
require 'pop_ssl' # I renamed the file from pop.rb to pop_ssl.rb to ensure I was requiring the correct version
username = 'YOUR_GMAIL_USERNAME@gmail.com'
password = 'YOUR_GMAIL_PASSWORD'
Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)
Net::POP3.start('pop.gmail.com', 995, username, password) do |pop|
if pop.mails.empty?
puts 'No mail.'
else
pop.each_mail do |mail|
p mail.header
end
end
end
Which I grabbed verbatim from the blogpost linked above.