This article mainly introduces php login methods through smtp mail verification, involving php connection, read/write, verification, and other related operation skills for SMTP mail servers through socket, for more information, see the example in this article. We will share this with you for your reference. The details are as follows:
Intranet systems use email accounts to log on to the same account. Therefore, the following procedures are available:
/*** Login via email verification * here you need to understand that the user name is with a 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) {// fclose ($ handle); return false;} fwrite ($ handle, 'Helo mystore '. "\ r \ n"); // indicates the identity. here, mystore writes $ mes = fgets ($ handle); // echo $ mes; if (! $ Mes) {fclose ($ handle); return false;} $ status = explode ("", $ mes); if ($ status [0]! = 250) {// server HELO failure 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 failure 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) {// 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) {// return false;} else {return true ;}}
The above is the php method for verifying login via smtp mail _ php skills. For more information, see PHP Chinese website (www.php1.cn )!