Friday, October 20, 2006

Access gmail INBOX from perl

Gmail provides pop3 access. You can set your gmail box for pop access using the settings link. They have detailed step by step guide for most of the clients. First I tried to access my gmail pop3 mail box using Net::pop3 module.(http://search.cpan.org)

No luck and I was wondering what is happening because the same program worked with other pop3 account. It took me a while to grasp that gmail is using pop3s (pop3 over SSL ) and net::pop3 has no SSL support ( I could be wrong , I did not dig very deep). But since gmail is such a nice and popular mbox there were plenty of links dealing with my issue.

My first try was to use GNU stunnel with Net::pop3 module. (http://www.stunnel.org) Stunnel can accept normal socket requests and forward as secure socket. I did stunnel install on windows XP. grab and install the windows MSI exe. Then copy the 2 DLLs (libeay and libssl) to your systems/win32 folder. And change the stunnel.conf file with accept and connect parameters. issue the command $stunnel --install to install stunnel as a windows service. Once stunnel is configured and running on your machine, you can use the localhost stunnel port for Net::Pop3. stunnel will then forward your requests over SSL.


schematics is perl Net::pop3 => normal => stunnel => SSL => gmail

However I could not get it to work. I tried creating and testing the localhost stunnel port from outlook but again no luck. maybe i was missing something with stunnel. I tried connecting using telnet and do a HELO but again no luck!!

I have a mac os x box at home. However before trying stunnel on that I just typed gmail cpan and out came GMail::Checker module. This module is a wrapper around gmail access. It took approx. 2 mins to run a sample program using Gmail::Checker on my mac os x box. ActiveState does not have Gmail::Checker module. So I really do not know how can I run my program on windows XP box. cygwin port of perl maybe ?
© Life of a third world developer
Maira Gall