Guest User

Untitled

a guest
Sep 23rd, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.90 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #
  3. # using pop3get -c will leave the mail on the server.
  4. #
  5.  
  6. use Net::POP3;
  7. use Mail::Message;
  8. use Getopt::Long;
  9. use Date::Manip;
  10. use DateTime::Format::Strptime;
  11. use warnings;
  12. use strict;
  13.  
  14. use vars qw($opt_c);
  15.  
  16. GetOptions("c!");
  17.  
  18. my $ServerName = "mail.net";
  19. my $pop3 = Net::POP3->new($ServerName, Debug => 0);
  20. my $UserName = "xxx";
  21. my $Password = "xxxx";
  22. my $inbox = "/tmp/";
  23. my $msg_id;
  24. my $email_dir = "/var/www/jc/";
  25.  
  26. die "Couldn't log on to server" unless $pop3;
  27. my $Num_Messages = $pop3->login($UserName, $Password);
  28. my $Messages = $pop3->list();
  29.  
  30.  
  31.  
  32. for $msg_id (keys(%$Messages)) {
  33.     print "Retriving Msg: $msg_id\n";
  34.     my $MsgContent = $pop3->get($msg_id);
  35.     my $DATE;
  36.  
  37.  
  38.         my $rawdata = $pop3->get($msg_id);
  39.         my $msg_obj = Mail::Message->read($rawdata);
  40.         my $body = $msg_obj->body;
  41.  
  42.  
  43.         print $body;
  44.  
  45. }
  46.  
  47. $pop3->quit();
Add Comment
Please, Sign In to add comment