欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php通過(guò)smtp郵件驗(yàn)證登陸的方法

 更新時(shí)間:2016年05月11日 10:41:21   作者:十一文  
這篇文章主要介紹了php通過(guò)smtp郵件驗(yàn)證登陸的方法,涉及php通過(guò)socket針對(duì)SMTP郵件服務(wù)器進(jìn)行連接、讀寫、驗(yàn)證等相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了php通過(guò)smtp郵件驗(yàn)證登陸的方法。分享給大家供大家參考,具體如下:

內(nèi)網(wǎng)的系統(tǒng)為了統(tǒng)一賬號(hào),都采用用郵件賬號(hào)登陸的方式,所以有了以下程序

/**
* 通過(guò)郵件 驗(yàn)證登陸
* 這里要明白的是用戶名是 帶域名的: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) { //鏈接服務(wù)器失敗
fclose($handle);
return false;
}
fwrite($handle, 'HELO mystore'."\r\n"); //表明身份,這里的mystore是隨便寫的
$mes = fgets($handle);
//echo $mes;
if(!$mes){
fclose($handle);
return false;
}
$status = explode(" ",$mes);
if($status[0] != 250) { //服務(wù)器HELO失敗
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) { //請(qǐng)求驗(yàn)證登陸失敗
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) { //驗(yàn)證用戶名失敗
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) { //驗(yàn)證密碼失敗
return false;
}else{
return true;
}
}

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php socket用法總結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》、《PHP圖形與圖片操作技巧匯總》、《php操作office文檔技巧總結(jié)(包括word,excel,access,ppt)》、《php日期與時(shí)間用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論