Mega-Mail-Delete
Monday, May 28th, 2007Have you ever had an email address that got so spammed that by the time you check it there are 7000+ emails there? Well, I have - and I’m not the kinda person to go through each one deleting them. I knocked up this script to simply empty a mail box.
Feel free to use and distribute at your will - however it is supplied ‘as is’ and no guarantees are given to its operation and usefulness - it did work well for me though! Its easy enough to figure out - if you don’t understand what to do don’t just guess, you may well end up in a hell of a (email less) state!
Be carefull though - it will delete every message in the mailbox defined!
// enter your POP3 mailbox username and password
$username = MAILBOX;
$password = PASSWORD;
//enter the address of your POP3 server - this is usually mail.domain.tld
$server = 'MAILSERVER';
//enter the port your server runs on - this is usually 110 for POP3
$port = 'PORT';
//Do not change anything below this line for normal (empty mailbox) opperation
$cmd = array();
$cmd[] = "USER $usernamern";
$cmd[] = "PASS $passwordrn";
$cmd[] = "STATrn";
$cmd[] = "QUITrn";
$fp = fsockopen($server, $port);
if(!$fp)
{
print("Error connecting to server $server");
}
else
{
$ret = fgets($fp, 1024);
foreach($cmd as $ret)
{
fputs($fp,$ret);
$line = fgets($fp, 1024);
print($line."");
if($ret=="STATrn")
{
$fields = explode(" ",$line);
$num_mails = $fields[1];
for($i=1;$i<=$num_mails;$i++)
{
fputs($fp,"DELE $irn");
$line = fgets($fp, 1024);
}
}
}
}





