How to authenticate in Gmail using Perl?

I installed this module to access and controls in the 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 a bug built into the Gmail.pm module.

I can ping the URL in question ( https://www.google.com/accounts/ServiceLoginBoxAuth ), so I feel the problem is not finding the URL. In addition, I know that the credentials are correct and work with this URL, because I tried them manually.

I am using this script for testing. I have provided my credentials in the appropriate places.


I also installed this module with the same type of errors. Any idea why I'm blocking?
+3
source share
5 answers

Use Mail :: IMAPClient as shown below. To obtain SSL authentication through Mail :: IMAPClient, you must install IO :: Socket :: SSL from Net :: SSLeay. If it 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(); 
+12
source

I successfully access my gmail account (more precisely, my Google Apps account) using Mail :: POP3Client

+2
source

If you cannot access gmail through regular POP3 or IMAP, then you have a configuration problem, not a programming problem.

I get mail from gmail (actually Google Apps that uses the same interface) using the configuration data described here: http://download.gna.org/hpr/fetchmail/FAQ/gmail-pop-howto.html

(This answer is much more suitable for Superuser though!)

+2
source

You can try with the following module

  Mail::Webmail::Gmail 
0
source

You can also use the following code

 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 = ' name@gmail.com '; 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; 
0
source

All Articles