Version: 0.00001
Type: Function
Category: Other
License: GNU General Public License
Description: This is a simple function that takes username, password, and pop server as arguments, and returns somewhat intelligent error codes.
<? function popAuth($user, $pass, $server) { $result=0; $sock = fsockopen("$server", 110, &$errno, &$errstr); if(!$sock) { //failed to connect $result=0; } else { set_socket_blocking($sock,-1); $rubbish = fgets($sock,128); //hold the banner fwrite($sock,"USER $userrn"); //user cmd $u = fgets($sock,128); $u = ereg_replace("n","",$u); //strip n if( ereg("^+OK(.+)", $u) ) { fwrite($sock,"PASS $passrn"); $p = fgets($sock,128); $p = ereg_replace("n","",$p); if( ereg("^+OK(.+)", $p) ) { //success $result = 10; } else { //wrong password $result = 2; } } else { //bad user name $result = 1; } fwrite($sock,"QUITrn"); fclose($sock); } return $result; } ?>