venerdì 22 gennaio 2010

Cancellare tutte le e-mail da un server pop3

Se la vostra casella e-mail risulta intasata con migliaia di messaggi vi risulterà utile il seguente script in php che vi elimina tutti i messaggi dalla casella.
Lo script è stato preso dal sito http://www.web-max.ca/PHP






set_time_limit(600);

$server = "pop3.myserver.com";
$username = "yourusername";
$password = "123456";


$cmd = array();
$cmd[] = "USER $username\r\n";
$cmd[] = "PASS $password\r\n";
$cmd[] = "STAT\r\n";
$cmd[] = "QUIT\r\n";

// Server is your POP3 server, ie pop3.server.com
// Port is the port number ( should be 110 )

$port = 110;


$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=="STAT\r\n")
{
$fields = explode(" ",$line);
$num_mails = $fields[1];
for($i=1;$i<=$num_mails;$i++)
{
fputs($fp,"DELE $i\r\n");
print("DELE $i
");
$line = fgets($fp, 1024);
print($line."
");

}
}
}
}



Nessun commento: