The example in this article describes the way that PHP validates the login via SMTP mail. Share to everyone for your reference, specific as follows:
Intranet system for the unified account, the use of mail account login method, so the following procedures
/** * by mail Verification login * Here to understand is that the user name is with domain name: aaa@163.com/function Valideemaillogin ($user, $pass, $smtp _server= ' smtp.163.com ', $ PORT=25) {$handle = Fsockopen ($smtp _server, $port); if (! $handle) return false; $mes = Fgets ($handle);//echo $mes; if (! $m
ES) {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]!= 220) {//Link server failed fclose ($handle); return false;} fwrite ($handle, ' HELO mystore '. ') \ r \ n ");
Identify, here's mystore is casually written $mes = fgets ($handle);
Echo $mes;
if (! $mes) {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]!= 250) {//server Helo failed fclose ($handle); return false;} fwrite ($handle, ' AUTH LOGIN '.]
\ r \ n ");
$mes = fgets ($handle);
Echo $mes;
if (! $mes) {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]!= 334) {//Request Verify Login Failed fclose ($handle); return false;} fwrite ($handle, Base64_encode ($user). "
\ r \ n ");
$mes = fgets ($handle);
Echo $mes;
if (! $mes) {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]!= 334 {//Verify user name failed fclose ($handle); return false;} fputs ($handle, Base64_encode ($pass). "
\ r \ n ");
$mes = fgets ($handle);
Echo $mes;
if (! $mes) {fclose ($handle); return false;} $status = Explode ("", $mes);
Fclose ($handle); if ($status [0]!= 235) {//Verify password failed return false;}
else{return true;}}
More about PHP Interested readers can view the site topics: "PHP Socket Usage Summary", "PHP Network Programming Skills Summary", "PHP Array" operation Skills Encyclopedia, "PHP Mathematical Operation Skills Summary", "PHP graphics and pictures Operating skills summary", " PHP Operations Office Document Tips summary (including word,excel,access,ppt), "PHP Date and Time usage summary", "PHP Introduction to Object-oriented Programming", "PHP string (String) Usage Summary", "php+ MySQL Database operations Introduction tutorial and PHP Common database operation Skills Summary
I hope this article will help you with the PHP program design.