2014-02-12 29 views
0
<?php 

    $sub="test"; 
    $msg="testing mail code"; 
    $to1="[email protected]"; //my active gmail id..i can receive mail here with same code. 
    $to2="[email protected]";//i set this invalid id dont get mail with same code because id not existed. 

    $to=$to1.','.$to2; 

    if(mail($to, $sub, $msg)) 
    { 
     ?> 
      <script > 
       alert('Message Sent..!!!!'); 
      </script> 
     <?php 
    } 
    else 
    { 
     ?> 
      <script > 
       alert('Oooooooop...... Message not Sent..!!!!'); 
      </script> 
     <?php 
    } 

    ?> 

電子郵件ID在具有2電子郵件我這個給定的代碼標識第一個是有效的和積極的,另一種是猜的ID是無效的,而不是存在任何地方。現在,即時消息發送郵件與此代碼它顯示我的消息,如消息發送.. !!!。我知道第二個電子郵件ID是錯誤的,所以第二個ID不能得到這個郵件,所以當一些ID像第二個ID時我怎麼可以提醒。哪些無法獲得ID或哪些ID無效。如何提醒交付報告在PHP郵件()時,不存在

+0

你無法知道馬上只是用郵件後()函數。它發送電子郵件,就這些。只有電子郵件服務器可以說,如果該電子郵件傳遞與否,但這一信息是不可用的PHP端。 – Hast

+0

檢查此鏈接http://www.daniweb.com/web-development/php/threads/141944/check-if-email-address-is-correct-without-sending-email – krishna

+0

thaks hast ...有沒有其他解決這個問題? – user3300358

回答

0
try it 

    $sub="test"; 
    $msg="testing mail code"; 
    $to1="[email protected]"; //my active gmail id..i can receive mail here with same code. 
    $to2="[email protected]";//i set this invalid id dont get mail with same code because id not existed. 


    $n = 2; /// number of emails id 
    for($i=1; $i==$n; $i++) 
    { 
     $element = $to.$i; 
     if(!isValidEmail($element)) 
     { 
      echo "<script>alert('Oooooooop...... Message not Sent..!!!!')</script>"; 
     } 
     else 
     { 
      if(mail($element, $sub, $msg)) 
      { 
       ?> 
        <script > 
         alert('Message Sent..!!!!'); 
        </script> 
       <?php 
      } 
      else 
      { 
       ?> 
        <script > 
         alert('Oooooooop...... Message not Sent..!!!!'); 
        </script> 
       <?php 
      } 
     } 
    } 

    function isValidEmail($element) { 
    return preg_match ("/^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$/", $element); 
} 
+0

我不想檢查身份證是否有效,但只是想知道我發送的郵件是誰()已成功發送或不能發送。 – user3300358

+0

如果郵件被成功接收,則返回TRUE,否則返回FALSE。 重要的是要注意,僅僅因爲郵件被接受發送,並不意味着郵件實際上會到達預定目的地。 – wild

+0

這裏我使用兩個ids從這兩個是正確的,另一個是錯誤的。它返回true這兩個ids.so如何我可以得到哪些郵件ID是錯誤的,當我將使用大量郵件在PHP郵件()。這就是爲什麼我需要送貨報告用於發送而不是發送郵件。 – user3300358