Get emails from server and save the emails to local drive : Mail « Network « Perl






Get emails from server and save the emails to local drive

    


use Mail::POP3Client;

$mail = new Mail::POP3Client("username", "password", "pop3.yourserver.com");

if ($mail->Count) {

    print "You have ", $mail->Count, " new message(s).\n";

    print "Storing message(s) to disk.\n";

    open FILEHANDLE, ">file.txt";

    for($loop_index = 1; $loop_index <= $mail->Count; $loop_index++) {

        print FILEHANDLE $mail->HeadAndBody($loop_index);

    }

    close FILEHANDLE;
}

   
    
    
    
  








Related examples in the same category

1.use Mail::POP3Client to send an email out
2.Send email out
3.Send email out with SMTP
4.Send mail
5.Sending mail with Net::SMTP on Windows
6.Open SENDMAIL