簡體   English   中英

有沒有辦法在PHP中檢查是否有任何電子郵件是活動的?

[英]Is there any way to check, in PHP, that whether any email is active or not?

有沒有辦法檢查(通過PHP)任何給定的電子郵件地址是否有效(意味着它當前是否被任何人使用和打開)(意味着它被阻止或沒有人使用/打開它,它是不活動的)?
提前問候並致謝。

有沒有辦法檢查(通過PHP)任何給定的電子郵件地址是否有效(意味着它當前是否被任何人使用和打開)(意味着它被阻止或沒有人使用/打開它,它是不活動的)?

沒有。

唯一可以確定的方法是向地址發送電子郵件,而不是收到退回郵件,並獲得某種回復(例如答案,或用戶點擊電子郵件中的唯一鏈接,或者打開一個唯一的URL的圖像[雖然這是令人不悅的,並被許多電子郵件客戶端阻止]或已讀回執)。 但是,這些方法都不是萬無一失的,所以你永遠無法100%確定。

我想你問的是電子郵件用戶輸入是否有效!! 如果是這種情況,那么你應該在exec的幫助下使用nslookup用於基於unix的操作系統..這里有一個小函數:(我正在檢查域是否正確)

function myCheckDNSRR($email)
{
      list($userName, $hostName) = split("@", $email); 
$recType = '';
if(!empty($hostName)) {
   if( $recType == '' ) $recType = "MX";

   exec("nslookup -type=$recType $hostName", $result);
   // check each line to find the one that starts with the host
   // name. If it exists then the function succeeded.

   foreach ($result as $line) {
     if(eregi("^$hostName",$line)) {
       return true;
     }
   }
   // otherwise there was no mail handler for the domain
   return false;
}
return false;

}

您可以但必須將API用於外部服務

有一些電子郵件驗證API,data8有一個。 http://www.data-8.co.uk/integr8/services/email_validation.aspx

這是一個例子

function IsValid($email, $level)
{
  $params = array(
    "username" => "your-username",
    "password" => "your-password",
    "email" => $email,
    "level" => $level,
    "options" => $options
  );
  $client = new SoapClient("http://webservices.data-8.co.uk/EmailValidation.asmx?WSDL");
  $result = $client->IsValid($params);
  if ($result->IsValidResult->Status->Success == 0)
  {
    echo "Error: " . $result->IsValidResult->Status->ErrorMessage;
  }
  else
  {
    // TODO: Process method results here.
    // Results can be extracted from the following fields:
    // $result->IsValidResult->Result
    //   Contains a status code indicating if the email address could be validated.
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM