texasag90 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to access my GMail account via IMAP/SSL and Perl using the following simple code. It is not working, and I cannot figure out why for the life of me. Any suggestions?

error is: new(): Unable to connect to imap.gmail.com: IO::Socket::SSL: connect: Connection timed out at ./imap-test5.pl line 6.

Thanks! Mark

Here is the code

#!/usr/local/bin/perl use Mail::IMAPClient; my $client = Mail::IMAPClient->new( Server => 'imap.gmail.com', Port => 993, Ssl => 1, User => 'foo@gmail.com', Password => 'foobar', ) or die "new(): $@"; print "I'm authenticated\n" if $client->IsAuthenticated();

Replies are listed 'Best First'.
Re: GMail IMAP SSL and Perl
by marto (Cardinal) on Jun 24, 2010 at 17:25 UTC

    Did you read the Mail::IMAPClient documentation regarding debugging?

    "Sets the debugging flag to either a true or false value. Can be supplied with the "new" method call or separately by calling the Debug object method. Use of this parameter is strongly recommended when debugging scripts and required when reporting bugs."

      I did, actually. It is not very helpful. It just says the connection timed out.
      Started at Thu Jun 24 17:01:06 2010 Using Mail::IMAPClient version 3.25 on perl 5.008008 Connecting via IO::Socket::SSL to imap.gmail.com:993 Timeout 600 ERROR: Unable to connect to imap.gmail.com: IO::Socket::SSL: connect: +Connection timed out at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPCl ient.pm line 339 Mail::IMAPClient::connect('Mail::IMAPClient=HASH(0x87cdeac)') +called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 3 00 Mail::IMAPClient::new('Mail::IMAPClient', 'Server', 'imap.gmai +l.com', 'Port', 993, 'Ssl', 1, 'User', 'foo@gmail.com', . ..) called at ./imap-test5.pl line 9

        So can you ping imap.gmail.com? Have you read Gmail IMAP access, apparently it is a working example.

Re: GMail IMAP SSL and Perl
by MidLifeXis (Monsignor) on Jun 24, 2010 at 17:26 UTC

    Does gmail give you any ideas?

    Update: ... or not. The above link appears to be a hack on the http(s) interface.

    --MidLifeXis

      I am embarrassed to admit that my problem was very aggressive firewall settings. SSL packets were not reaching orbit. Sorry to have wasted your time. Thanks, Mark