Intranet systems use email accounts to log on to the same account. Therefore, the following program is used to ** log on via email verification **. here we need to understand that the user name includes a Domain Name: aaa@163.com * functionvalideEmailLogin ($ user, $ pass, $ smtp_serversmtp.163.com, $ port25) {$ handlefsoc
Intranet systems use email accounts to log on to the same account, so with the following Program/*** 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 = fsoc
Intranet systems use email accounts to log on to the same account. Therefore, the following procedures are available:
/**
* Verify login by email
* 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) {// failed to connect to the server
Fclose ($ handle );
Return false;
}
Fwrite ($ handle, 'helo mystore'. "\ r \ n"); // indicates the identity. Here, mystore is written at will.
$ 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) {// login request verification 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) {// An error occurred while verifying the user name
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) {// password verification failed
Return false;
} Else {
Return true;
}
}