Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jmcada (5846)

  (email not shown publicly)

Journal of jmcada (5846)

Thursday May 19, 2005
08:26 PM

Gmail Access

[ #24782 ]

Okay, I needed to access my Gmail from a script, so I lurked about CPAN looking for an answer. At first I had the bright idea to access my mail via the Net::Pop3 module, but then stumbled across a ton of Gmail-specific modules. The ones that I tried were WWW::GMail, Mail::Webmail::Gmail, and finally GMail::Checker. Wow I thought. After finding all of these modules accessing my Gmail should be a breeze... WRONG!

First off, WWW::GMail told me that it wasn't smart enough. No, I'm serious, check out the error message:

"unknown error (module not smart enough)"

Well, next came Mail::Webmail::Gmail. Instead of giving me an error, this module just didn't return anything, even though I had mail in my inbox.

At this point, I'm just about fustrated. I decided to give GMail::Checker a test just so that I can get really pissed. However, this module does work. It took me a little while to figure it out, but it does work. The figuring it out part was mostly just fustrated user error anyway and now I have a script that can pull importantant messages from my inbox automatically... SWEET.

After I got everything working, it was time to go back and see why two out of three modules couldn't cut it. It turns out that the two that wouldn't work for me were using HTTP to interface with GMail and I guess GMail has changed since they were last updated. The GMail::Checker was acting like a POP3 agent on my behalf and seems to be doing fine.

One note for anybody who is going to try to check GMail with GMail::Checker... don't explicitly close your connection while testing. GMail makes messages go away or at least won't let POP3 pick them back up... I can't remember exactly which right now... I just remember that it was trouble when I was constantly re-running my script through development. Just leave the socket hanging and make GMail think that you didn't exit cleanly and your message will be sitting in your inbox when you log in through the web interface and will be re-downloadable over POP3.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Uhm, I think what you’re seeing is the server marking the entries as read and the module requesting only unread messages. You can re-retrieve those using POP3, but I don’t remember specifics and obviously I have no idea whether Gmail::Checker (what a horribly chosen name) exposes an interface for that.