I am trying to make a simple web tool that will log into a POP3 mailbox and
delete the messages all at once. I have came up with this and if the Login
information is correct it does delete the mail,but if the login info is
incorrect you do not know until after you try to login to the mailbox again
via telnet or anything like that and notice that the mail is still there.
Does anyone have any idea how I could make this script so it will tell us
that the information is incorrect? Any help would be appreciated. Thanks in
advance.
<?
$host = $_POST['address'];
$user = $_POST['username'];
$pass = $_POST['password'];
############### ############### ############### ############### ###########
# End Configuration #
############### ############### ############### ############### ###########
#Until I rewrite my scripts, this will suffice for bg-compatibility;
if(phpversion() >= "4.2.0"){
extract($_POST) ;
extract($_SERVE R);
extract($_ENV);
}
#Format output for console or for web?
$nl = ((isset($REMOTE _ADDR)) ? "<br>" : "\n");
if(!$sock=fsock open($host, 110, $err, $errno, 10))
die("Couldn't connect to the POP server$nl");
fputs($sock, "USER $user\r\n");
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like USER $user$nl");
fputs($sock, "PASS $pass\r\n");
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like PASS$nl");
fputs($sock, "STAT\r\n") ;
$buf = fgets($sock, 1024);
fputs($sock, "STAT\r\n") ;
$buf2 = fgets($sock, 1024);
list($stat, $num, $size) = split(' ', $buf2, 3);
echo "Mailbox has $num messages$nl";
for($i=1; $i<=$num; $i++){
$command = "DELE $i\r\n";
echo "Deleting message $i with DELE $i$nl";
fputs($sock, $command);
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like DELE $i: ($buf)$nl");
}
fputs($sock, "QUIT\r\n") ;
$buf = fgets($sock, 1024);
fclose($sock);
?>
delete the messages all at once. I have came up with this and if the Login
information is correct it does delete the mail,but if the login info is
incorrect you do not know until after you try to login to the mailbox again
via telnet or anything like that and notice that the mail is still there.
Does anyone have any idea how I could make this script so it will tell us
that the information is incorrect? Any help would be appreciated. Thanks in
advance.
<?
$host = $_POST['address'];
$user = $_POST['username'];
$pass = $_POST['password'];
############### ############### ############### ############### ###########
# End Configuration #
############### ############### ############### ############### ###########
#Until I rewrite my scripts, this will suffice for bg-compatibility;
if(phpversion() >= "4.2.0"){
extract($_POST) ;
extract($_SERVE R);
extract($_ENV);
}
#Format output for console or for web?
$nl = ((isset($REMOTE _ADDR)) ? "<br>" : "\n");
if(!$sock=fsock open($host, 110, $err, $errno, 10))
die("Couldn't connect to the POP server$nl");
fputs($sock, "USER $user\r\n");
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like USER $user$nl");
fputs($sock, "PASS $pass\r\n");
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like PASS$nl");
fputs($sock, "STAT\r\n") ;
$buf = fgets($sock, 1024);
fputs($sock, "STAT\r\n") ;
$buf2 = fgets($sock, 1024);
list($stat, $num, $size) = split(' ', $buf2, 3);
echo "Mailbox has $num messages$nl";
for($i=1; $i<=$num; $i++){
$command = "DELE $i\r\n";
echo "Deleting message $i with DELE $i$nl";
fputs($sock, $command);
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like DELE $i: ($buf)$nl");
}
fputs($sock, "QUIT\r\n") ;
$buf = fgets($sock, 1024);
fclose($sock);
?>