use CGI::Carp qw(fatalsToBrowser); use Net::POP3; use strict; ############# Pop-Postfach einlesen sub check_pop{ my $pop3Server = shift; my $user = shift; my $passwd = shift; my $spam = 0; my ($msgnum,$mailcontent); my ($subject,$from,$zeile); my $pop3 = Net::POP3->new($pop3Server); print "<h1>Einloggen in $pop3Server ...</h1>\n"; if ($pop3->login($user, $passwd) > 0){ my $messagenum = $pop3->list; my $msgnums = $pop3->list; # hashref of msgnum => size my $nummer=keys %$msgnums; print "<b>Es gibt $nummer neue Nachrichten</b><br>\n"; my $cou=0; foreach $msgnum (keys %$msgnums) {$cou++; my $subject = $pop3->top($msgnum); #subject suchen foreach $zeile (@$subject) { #print $zeile; if (index($zeile,"Subject:")>=0) { $subject=$zeile; } #From suchen if ($zeile=~ /From\:/) { $from=$zeile; $from=~ s/From\://; $from=~ s/^\s+//g; $from=~ s/\s+$//g; my @from=split (" ",$from); if (@from != 1){$from=$from[-1]; $from=~ s/[<>]//g; } } # hier könnte man noch nach cc: und bcc: usw. suchen } # content durchsuchen my $content=0; #content start my $msg = $pop3->get($msgnum); foreach my $akzeile (@$msg){ if ($content == 0){ if ($akzeile=~ /^content/i){$content=1;} else {next;} } $mailcontent.=$akzeile; } } #if ($spam >= 100){print "<b>SPAM </b>"; #$pop3->delete($msgnum); print "gelöscht "; #} print <<EOF; $cou: $subject\n From: $from\n $mailcontent EOF } else { print "Konnte nicht in $pop3Server einloggen oder keine neue Nachricht vorhanden\n"; } $pop3->quit(); } |