Hey Monks,
I'm writing a little utility to clean up a POP3 account from spam before I get my mail. So far the code looks something like this..
$spamx = $spamdir.$spamfile;
$pop = new Mail::POP3Client( USER => $account,
PASSWORD => $passwd,
HOST => $server) || die $pop->Message();
#$pop->Connect() >= 0 || die $pop->Message();
for( $i = 1; $i <= $pop->Count(); $i++ )
{
foreach( $pop->Head( $i ) )
{
if(/^(X-Spam-Score):\s+/i)
{
$_ =~ s/[a-z \(\-\):,_\*\s]//ig;
chomp;
if($_ > $threshold)
{
open(OUT, ">>$spamx") || open(OUT,">$spamx") || die
+ "could not open Spam file ";
$pop->Retrieve($i);
if(print OUT $pop->Body($i), "\n\n")
{
$pop->Delete($i);
}
else
{
print "Spam filter file can't be written too, Stoppin
+g Program \n\n";
exit;
}
close(OUT);
print $_ , "\n";
}
}
} # end foreach loop #
} # end for every message in spool #
$pop->Close();
Everything is working okay, no real problems, except the Delete. When I run the program twice against the same account the first run marks all of them as deleted, and the second run shows no mail found, but when I check the server que, or open a mail client (Eudora) against the same account, I get all the emails that should have been deleted. ??? and were seen as deleted by the above code. ??
I'm probably overlooking something stupid, and should just stop, drink lots of woopass and howl at the moon for a while, but thought I would see if one of you have had experinence with this problem, and hopfully could explain it to my tired mind.
Checked the back area, before I asked, didn't find anything, but if I missed it, sorry.
webadept
"Yeah, but you are taking the whole universe out of context"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.