note 35069 deleted from function.fsockopen by cece
| From: | cece@php.net | Date: | Mon, 18 Aug 2003 16:31:07 +0000 |
| Subject: | note 35069 deleted from function.fsockopen by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54606@lists.php.net to get a copy of this message | ||
Note Submitter: Gledison Souza
----
<?
/*
Script: Mailbox cleaner
Version: 1.0
Author: Gledison Souza
Homepage: http://lugar.com.br/download/
Date: 08/16/2003
Description: This simple script clear all e-mails of an pop3 account.
Attention: Use this software at your own risk.
I will not be responsible for any damage caused.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation
Instructions:
1-Remove ".txt" extension of this script.
2-Configure the script with your POP3 server, login and password.
3-Put this on your server.
4-If you are sure, run the script on your server by http connection.
5-Your mailbox is now empty!
Be sure you want to clear your mailbox! It's irreversible!!!
*/
// mail server settings
$host = "xxx";
$port = 110;
$user = "xxx";
$pass = "xxx";
// end of settings
// open a client connection
$fp = fsockopen ($host, $port, $errno, $errstr);
// if a handle is not returned
if (!$fp)
{
die("Error: could not open socket connection\n");
}
else
{
echo "Connection ok\n<br>";
// get the welcome message
$welcome = fgets ($fp, 150);
//echo "$welcome\n<br>";
// check for success code
if (substr($welcome, 0, 3) == "+OK")
{
// send username and read response
fputs ($fp, "USER $user\n");
fgets($fp, 50);
// send password and read response
fputs ($fp, "PASS $pass\n");
$ack = fgets($fp, 150);
//echo "$ack\n<br>";
// check for success code
if (substr($ack, 0, 3) == "+OK")
{
// send status request and read response
fputs ($fp, "STAT\n");
$status = fgets($fp, 150);
//echo "$status\n<br>";
if (substr($status, 0, 3) == "+OK")
{
$arr = explode(" ", $status);
$total = $arr[1];
echo "Total = $total messages\n<br>";
echo "Cleaning progress:\n<br>";
for ($i = 1; $i <= $total; $i++) {
fputs ($fp, "DELE $i\n");
fgets($fp, 150);
print ".";
}
echo "<br>Process complete. Your mailbox is now empty!\n<br>Closing
conection\n<br>";
// shut down connection
fputs ($fp, "QUIT\n");
fclose ($fp);
echo "Connection closed! Bye";
}
// error getting status
else
{
die ("Server said: $status");
}
}
// auth failure
else
{
die ("Server said: $ack");
}
}
// bad welcome message
else
{
die ("Bad connection string\n");
}
// get status string
// split by spaces
$arr = explode(" ", $status);
/*
// the second element contains the total number of messages
echo $arr[1] . " messages in mailbox";
echo "<br>";
foreach ($message as $key=>$value)
echo "$value<br>";
*/
}
?>