脚本宝典收集整理的这篇文章主要介绍了检查电子邮件是否存在php,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
但似乎雅虎,hotmail,aol和其他提供商正在接受任何电子邮件,而不是拒绝无效的电子邮件.
只有Gmail和许多像stackoverflow.COM这样的域名都拒绝了没有虚假的电子邮件.
检查我的脚本,让我知道我是否可以做一些检查雅虎和其他人.
htML帖子表格
<html> <body> <form action="checkemail.PHP" method="POST"> <b>E-mail</b> <input tyPE="text" name="email"> <input type="submIT"> </form> </body> </html>
<?PHP /* Validate an email address. */ function jValidateEmailUsingSMTP($sToEmail,$sFromDomain = "gmail.com",$sFromEmail = "email@gmail.com",$bIsDebug = false) { $bIsValid = true; // assume the address is valid by default.. $aEmailParts = explode("@",$sToEmail); // extract the user/domain.. getmxrr($aEmailParts[1],$aMatches); // get the mx records.. if (sizeof($aMatches) == 0) { return false; // no mx records.. } foreach ($aMatches as $oValue) { if ($bIsValid && !isset($sResponseCode)) { // open the connection.. $oConnection = @fsockopen($oValue,25,$errno,$errstr,30); $oResponse = @fgets($oConnection); if (!$oConnection) { $aConnectionLOG['Connection'] = "ERROR"; $aConnectionLog['ConnectionResponse'] = $errstr; $bIsValid = false; // unable to connect.. } else { $aConnectionLog['Connection'] = "SUCCESS"; $aConnectionLog['ConnectionResponse'] = $errstr; $bIsValid = true; // so far so good.. } if (!$bIsValid) { if ($bIsDebug) PRint_r($aConnectionLog); return false; } // say hello to the server.. fputs($oConnection,"HELO $sFromDomain\r\n"); $oResponse = fgets($oConnection); $aConnectionLog['HELO'] = $oResponse; // send the email from.. fputs($oConnection,"MAIL FROM: <$sFromEmail>\r\n"); $oResponse = fgets($oConnection); $aConnectionLog['MailFromResponse'] = $oResponse; // send the email to.. fputs($oConnection,"RCPT TO: <$sToEmail>\r\n"); $oResponse = fgets($oConnection); $aConnectionLog['MailToResponse'] = $oResponse; // get the response code.. $sResponseCode = substr($aConnectionLog['MailToResponse'],3); $sBaseResponseCode = substr($sResponseCode,1); // say goodbye.. fputs($oConnection,"QUIT\r\n"); $oResponse = fgets($oConnection); // get the quit code and response.. $aConnectionLog['QuitResponse'] = $oResponse; $aConnectionLog['QuitCode'] = substr($oResponse,3); if ($sBaseResponseCode == "5") { $bIsValid = false; // the address is not valid.. } // close the connection.. @fclose($oConnection); } } if ($bIsDebug) { print_r($aConnectionLog); // output debug info.. } return $bIsValid; } $email = $_POST['email']; $bISEMailValid = jValidateEmailUsingSMTP("$email","gmail.com","email@gmail.com"); echo $bIsEmailValid ? "<b>Valid!</b>" : "Invalid! :("; ?>
以上是脚本宝典为你收集整理的检查电子邮件是否存在php全部内容,希望文章能够帮你解决检查电子邮件是否存在php所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。