note 72576 added to function.fsockopen

From: Date: Wed, 24 Jan 2007 23:01:38 +0000
Subject: note 72576 added to function.fsockopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-122162@lists.php.net to get a copy of this message
The following function performs pop3 authentication. Returns NULL on error, or true/false to indicate username/password matching: $address is the hostname of the server and $ssl is a boolean that indicates whether an SSL connection is requested. <?php function pop3authCheck($username, $password, $address, $ssl) { if ($ssl) $uri="ssl://$address:995"; else $uri="tcp://$address:110"; $fp=fsockopen($uri); if (!$fp) return(NULL); $st=fgets($fp, 512); if (substr($st, 0, 3)!="+OK") { fclose($fp); return(NULL); } $st="USER $username\n"; if (fwrite($fp, $st)!=strlen($st)) { fclose($fp); return(NULL); } $st=fgets($fp, 512); if (substr($st, 0, 3)!="+OK") { fclose($fp); return(NULL); } $st="PASS $password\n"; if (fwrite($fp, $st)!=strlen($st)) { fclose($fp); return(NULL); } $st=fgets($fp, 512); fclose($fp); if (substr($st, 0, 3)=="+OK") return(true); else if (substr($st, 0, 4)=="+ERR") return(false); else return(NULL); } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 194.219.216.207 (proxied: 127.0.0.1) ---- Manual Page -- http://www.php.net/manual/en/function.fsockopen.php Edit -- https://master.php.net/note/edit/72576 Del: integrated -- https://master.php.net/note/delete/72576/integrated Del: useless -- https://master.php.net/note/delete/72576/useless Del: bad code -- https://master.php.net/note/delete/72576/bad+code Del: spam -- https://master.php.net/note/delete/72576/spam Del: non-english -- https://master.php.net/note/delete/72576/non-english Del: in docs -- https://master.php.net/note/delete/72576/in+docs Del: other reasons-- https://master.php.net/note/delete/72576 Reject -- https://master.php.net/note/reject/72576 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122162) next »