Hi Experts.,

i written One email recieving 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 solved my thread.,

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 connect to $mailserver";
my $tot_msg = $pop3->login($username,$password) or die "Failed to authenticate $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);
}

As does Yahoo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.