Retrieve mail using perl plz help me

Discussion in 'Perl' started by rahul_mawana, Nov 7, 2009.

  1. rahul_mawana

    rahul_mawana New Member

    Joined:
    Apr 4, 2009
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    0
    Hello frnds,
    I am trying to makd a perl propram by that i can retrieve my email from a server that requires SSL
    authentication. I used
    Net::POP3 and I tried all the
    different types of logging in such as auth(..), login(..),
    which are sub routines defined in
    Net::POP3.
    But not working plz tell me any method or perl module by that i can retrive mail.
    Thanks
     
  2. murugaperumal

    murugaperumal New Member

    Joined:
    Feb 20, 2010
    Messages:
    15
    Likes Received:
    1
    Trophy Points:
    0
    Dear Friend,

    You can use the following modules

    Mail::POP3Client

    It will help your requirement.
     
  3. ungalnanban

    ungalnanban New Member

    Joined:
    Feb 19, 2010
    Messages:
    45
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    Chennai
    Refer the following link

    http://bumppo.net/lists/macperl-webcgi/2000/05/msg00027.html
     
  4. murugaperumal

    murugaperumal New Member

    Joined:
    Feb 20, 2010
    Messages:
    15
    Likes Received:
    1
    Trophy Points:
    0
    You can use the following code

    Code:
     
     use warnings;
    use strict;
    use Mail::POP3Client;
    use lib "/home/murugaperumal/.perl_m/share/perl/5.8.8/" ;
    use IO::Socket::SSL;
    use CGI qw(:standard);
    my $cgi = new CGI;
    my $LOG ;
    open $LOG , ">>filename" ;
    my $username  = 'username@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;
    
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice