views:

897

answers:

5

I've installed this module to gain access and controls within a Gmail inbox. However, when I try to connect through a small Perl script and test the functionality, I get this error message.

Error: Could not login with those credentials - could not find final URL
  Additionally, HTTP error: 200 OK

This is an error built within the Gmail.pm module.

I can ping the URL in question ( https://www.google.com/accounts/ServiceLoginBoxAuth ) so I feel that the trouble isn't finding the URL. Furthermore, I know the credentials are correct and work at that URL because I have tried them manually.

I'm using this script for testing. I have supplied my credentials in the appropriate places.


I've also installed this module with the same type of error.

Any idea why I'm getting blocked?

+2  A: 

I am successfully accessing a gmail account (google apps account to be precise) using Mail::POP3Client

hhunter
thanks.... looks like it might be connecting (no error msgs) but it doesn't output anything as per the first example code listed at cpan
CheeseConQueso
coffeepac
yeah that's enabled
CheeseConQueso
Did you check the return $pop->Count() after connecting? -1 indicates an error, otherwise you're in busienss
hhunter
+2  A: 

If you cannot access gmail through normal POP3 or IMAP either, then you have a configuration problem rather than a programming problem.

I fetch my mail from gmail (actually Google Apps, which uses the same interface), using configuration details described here: http://download.gna.org/hpr/fetchmail/FAQ/gmail-pop-howto.html

(This answer is far more appropriate for Super User though!)

Ether
+3  A: 

Use Mail::IMAPClient as shown below. To get pass SSL authentication through Mail::IMAPClient, you should have IO::Socket::SSL from Net::SSLeay installed. If so this works like a charm.

#!/usr/bin/env perl
use strict; use warnings;
use Mail::IMAPClient;

# Connect to IMAP server
my $client = Mail::IMAPClient->new(
  Server   => 'imap.gmail.com',
  User     => 'yourusername',
  Password => 'yourp4a55w0r&',
  Port     => 993,
  Ssl      =>  1,
  )
  or die "Cannot connect through IMAPClient: $!";

# List folders on remote server (see if all is ok)
if ( $client->IsAuthenticated() ) {
  print "Folders:\n";
  print "- ", $_, "\n" for @{ $client->folders() };  
};

# Say so long
$client->logout();
i-blis
that connected me.... thanks.... now to browse the module for methods
CheeseConQueso
whats the method(s) to parse messages?
CheeseConQueso
nvm... i got it
CheeseConQueso
A: 

You can tried with the following module

  Mail::Webmail::Gmail
muruga
This is what he did. But the module is most probably out-of-date.
i-blis
A: 

You can use the following code also

use warnings;
use strict;
use Mail::POP3Client;
use IO::Socket::SSL;
use CGI qw(:standard);
my $cgi = new CGI;
my $LOG ;
open $LOG , ">>filename" ;
my $username  = '[email protected]';
my $password  = '*******' ;
 chomp($password);
my $mailhost  = 'pop.gmail.com';
my $port      = '995';

$cgi->header();

my $pop = new Mail::POP3Client(
USER     => $username,
PASSWORD => $password,
HOST     => $mailhost,
PORT     => $port,
USESSL   => 'true',
DEBUG     => 0,
);
if (($pop->Count()) < 1) {
exit;
}

print $pop->Count() . " messages found!:$!\n";

for(my $i = 1; $i <= $pop->Count(); $i++) {
 foreach($pop->Head($i)) {
 /^(From|Subject|Email):\s+/i && print $_, "\n";
 }

$pop->BodyToFile($LOG,$i);

}

$pop->Close();

exit;
muruga