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

Hi Experts.,

i written One email receiving code by using Perl Modules with CGI. here i have getting one error

"Failed to connect to pop3.gmail.com at mail.pl line 14, <STDIN> line 3."., but i am trying to connect my gmail account and yahoo too., Otherwise let me know which module is suitable to retrieve the mails., still i am getting same error.,

i hope any one can help to me. i belowed mention the code

Advance Thanks.,

Senthil. V

chennai

India

use warnings; use strict; use Net::POP3; my $subject_width = 50; my $from_width = 80; print "Mail Server: "; my $mailserver = <STDIN>; print "Username: "; my $username = <STDIN>; print "Password: "; my $password = <STDIN>; chomp ($mailserver, $username, $password); my $pop3 = Net::POP3->new($mailserver) or die "Failed to conn +ect to $mailserver"; my $tot_msg = $pop3->login($username,$password) or die "Failed to auth +enticate $username"; printf("\n There are $tot_msg messages\n\n"); foreach my $msg_id (1 .. $tot_msg) { my $header = $pop3 -> top($msg_id, 0); my ($subject, $from, $status) = analyze_header($header); my $delete = ""; if ($subject eq 'Document') { $delete = 'del'; $pop3->delete($msg_id); # not really deleted until quit is called } printf "[%3d] %-${subject_width}s %-${from_width}s %6s %3s\n", $msg_id, substr($subject,0,$subject_width), substr($from ,0,$from_width ), $status, $delete; } print "Quit and Delete?\n"; my $quit = <STDIN>; chomp $quit; if (lc $quit eq 'y' or lc $quit eq 'yes') { print "quitting and deleting\n"; $pop3 -> quit; # deleted messages are deleted now } sub analyze_header { my $header_array_ref = shift; my $header = join "", @$header_array_ref; my ($subject) = $header =~ /Subject: (.*)/m; my ($from ) = $header =~ /From: (.*)/m; my ($status ) = $header =~ /Status: (.*)/m; if (defined $status) { $status = "Unread" if $status eq 'O'; $status = "Read" if $status eq 'R'; $status = "Read" if $status eq 'RO'; $status = "Ne $status = "-";w" if $status eq 'NEW'; $status = "New" if $status eq 'U'; } else { $status = "-"; } return ($subject, $from, $status); }

Replies are listed 'Best First'.
Re: I cant recieve the mails from Gmail or any other account
by Corion (Patriarch) on Feb 14, 2011 at 17:49 UTC

    This is not a Perl problem.

    Once you enter a server name that actually exists, the program will likely work.

    Search (Google) for how to enable and configure POP. Maybe test with another POP client. Or use IMAP.

Re: I cant recieve the mails from Gmail or any other account
by ikegami (Patriarch) on Feb 14, 2011 at 18:05 UTC
    There's a good chance $! contains something relevant in this specific case.
Re: I cant recieve the mails from Gmail or any other account
by cjb (Friar) on Feb 15, 2011 at 09:07 UTC