看advprog里面的Perl代码,自己试验了一下,很好用。主要是把新浪邮箱里我不关心的邮件统统删除。
#!/usr/local/bin/perl
use Net::POP3;
$m = Net::POP3->new('pop.sina.com.cn'); # Name of POP server
die "Could not open account" unless $m;
$n = $m->login('xxxx', 'xxxx'); # Login, passwd
print "Number of msgs received: $n/n";
$r_msgs = $m->list(); # Returns a ref-to-hash mapping
# msg_id to msg_size
foreach $msg_id (keys %$r_msgs) {
$rl_msg = $m->top($msg_id); # Get top three lines from message
foreach my $line (@$rl_msg) {
unless ($line =~ /@163/.com/is) { #只要不是从163来的信件,统统删除
$m->delete($msg_id) or warn "can't delete mail/n";
print $line;
}
}
}
$m->quit();
#!/usr/local/bin/perl
use Net::POP3;
$m = Net::POP3->new('pop.sina.com.cn'); # Name of POP server
die "Could not open account" unless $m;
$n = $m->login('xxxx', 'xxxx'); # Login, passwd
print "Number of msgs received: $n/n";
$r_msgs = $m->list(); # Returns a ref-to-hash mapping
# msg_id to msg_size
foreach $msg_id (keys %$r_msgs) {
$rl_msg = $m->top($msg_id); # Get top three lines from message
foreach my $line (@$rl_msg) {
unless ($line =~ /@163/.com/is) { #只要不是从163来的信件,统统删除
$m->delete($msg_id) or warn "can't delete mail/n";
print $line;
}
}
}
$m->quit();