in reply to Almost success

If by "But!We see many unnecessarys information....;( i want to see only message, but i don't know how to write this" you mean you don't want to see the headers preceding the content body, you simply need to skip them when output the message. Headers in smtpd are delimited by an empty line or two newlines in a row. For example:
while( my $line = shift @$msg ) { last unless length $line; } for( @$msg ) { print "Body: $_"; }
The first while loop removes the first element from the array each time it loops. If the element is empty, signifying we have reached the end of the headers, we exit the loop. The next loop can simply print the remainder.

I should note that you are unlikely to acheive good results if you have some sort of multipart message, you might want to consider using an actual parser from CPAN.

Replies are listed 'Best First'.
Re^2: Almost success
by w3b (Beadle) on Dec 04, 2005 at 07:17 UTC
    Thank you very very much^^ now my script looks nice^^ Here is source:
    #!/usr/bin/perl use warnings; use strict; use Net::POP3; my $time = scalar localtime; my $pop3 = "pop3.poczta.onet.pl"; my $login = "haptor\@op.pl"; my $pass = "******************"; my $pop = Net::POP3->new($pop3); my $res = $pop->login($login, $pass); if ($res){ print"On $time e-mail status inbox: $res post \n"; } else { print "Couldn't connect $!\n"; exit; } my $msg; my $msgnum; do{ print "Write id(number) email to read subject:\n"; chomp($msgnum = <STDIN>); } while($msgnum > $res); $msg = $pop->get($msgnum); for my $line ( @$msg ) { if( $line =~ /^Subject:(.*)/ ) { print "Subject is $1\n"; last } } print "Read e-mail? [y/n]\n"; chomp(my $ans = <STDIN>); if ($ans =~ /y/i){ while( my $line = shift @$msg ) { last while $line =~ /^Status:/; } my $nline = 0; for( @$msg ) { $nline += 1; print "$nline> $_"; } } elsif ($ans =~ /n/i){ exit; } else { print "Bad!"; exit; } $pop->quit();
    If somebody use this scripts i'll be very happy^^ i love Perl;p