Checking Gmail POP+SSL with Ruby 1.8.6 in 10 minutes or less.

I needed to check Gmail via POP + SSL and didn’t want to use Ruby 1.9, what did I do?

Step 1: Install the latest version of stunnel

Step 2: Put the contents of the stunnel config file you see below some place convenient like ~/gmail-pop-stunnel.conf

foreground = yes

client = yes

pid =

[gmail]

delay = yes

accept = localhost:10000

connect = pop.gmail.com:995

Step 3: Start up stunnel

$ stunnel ~/gmail-pop-stunnel.conf &

Step 4: Fire up a Ruby program to pull down the messages.

require ‘net/pop’

conn = Net::POP3.new(’localhost:10000′)

conn.start(’youraddress@gmail.com’, ‘yourpassword’)

conn.mails.each { |msg| puts msg.pop }

msg.delete # your choice to delete or not

end

The source for this script shamelessly stolen from The Ruby Cookbook

And you should be aware that this is technically a violation of google’s terms of service, but if you aren’t doing anything other than what you could do through Outlook Express you probably aren’t causing trouble.

Leave a Reply