Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w use Net::POP3; # Connect to pop3 server my $pop3 = Net::POP3->new("10.10.10.10") || die "Error : Couldn't log +on to server"; # Login to pop3 server my $Num_Message = $pop3->login("dummy", "dummy"); my $Messages = $pop3->list(); my ($MsgId, $MsgDate, $MsgFrom, $MsgTo, $MsgCc, $MsgSub); my ($MsgAttach, $MsgSize, $MsgHeader, $MsgHeadFlg, $MsgBody); foreach $MsgNo (keys %$Messages) { my $MsgContent = $pop3->get($MsgNo); my $count = 0; $MsgHeadFlg = 0; $MsgBody = ""; print "Message No : $MsgNo\n"; $MsgSize = $pop3->list($MsgNo); print "Message Size : $MsgSize Bytes\n"; # Process message data while() { # Exit if last line of mail if ($count >= scalar(@$MsgContent)) { print "$MsgBody"; last; } # Check if end of mail header if (@$MsgContent[$count] =~ /^\n/) { $MsgHeadFlg = 1; } # Proceed if message header not processed if (not $MsgHeadFlg) { # Split the line my @LineContent = split /: /, @$MsgContent[$count]; # Check Header Info SWITCH: { # Get message date $LineContent[0] =~ /Date/i && do { $MsgDate = $LineContent[1]; print "Date : $MsgDate"; last SWITCH; }; # Get message id $LineContent[0] =~ /Message-ID/i && do { $MsgId = $LineContent[1]; print "Message ID : $MsgId"; last SWITCH; }; # Get message from $LineContent[0] =~ /From/i && do { $MsgFrom = $LineContent[1]; print "From : $MsgFrom"; last SWITCH; }; # Get message to $LineContent[0] =~ /To/i && do { $MsgTo = $LineContent[1]; print "To : $MsgTo"; last SWITCH; }; # Get message cc $LineContent[0] =~ /Cc/i && do { $MsgCc = $LineContent[1]; print "Cc : $MsgCc"; last SWITCH; }; # Get message subject $LineContent[0] =~ /Subject/i && do { $MsgSub = $LineContent[1]; print "Subject : $MsgSub"; last SWITCH; }; } } else { # Process message body $MsgBody .= @$MsgContent[$count]; } $count++; } } # Disconnect from pop3 server $pop3->quit();

In reply to Simple POP 3 Client Ver 1.0 by Jamnet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-24 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found