PHP authentication via SMTP mail login method, PHPSMTP mail authentication
This article explains how PHP logs on through SMTP mail verification. Share to everyone for your reference, as follows:
Intranet system in order to unify the account, all use the mail account login way, so there are the following procedures
/*** via email authentication * Here to understand is the user name is with the 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 (! $mes {fclose ($handle); return false;} $status = Explode ("", $mes); if ($status [0]! = 220) {//Link server failed fclose ($handle); return false;} Fwrite ($handle, ' HELO mystore '. \ r \ n "); Indicate identity, where the 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 verification 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 related content readers can view this site topic: "PHP Socket Usage Summary", "PHP Network Programming Skills Summary", "PHP array" operation Skills Daquan, "PHP Math Skills Summary", "PHP graphics and pictures Operation Skills Summary", " PHP Operations Office Documentation Tips Summary (including word,excel,access,ppt), PHP date and Time usage summary, PHP Object-oriented Programming primer tutorial, PHP string Usage Summary, php+ MySQL database operation Getting Started tutorial and PHP Common database operation Skills Summary
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1125879.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125879.html techarticle PHP through the SMTP mail authentication method, PHPSMTP mail authentication This article describes the PHP through the SMTP mail authentication method of landing. Share to everyone for reference, as follows: Intranet ...