2017-02-22 91 views
0

這是我的第一篇文章。是啊!如何避免垃圾箱與PHP郵件()函數

我的聯繫表單出現問題。它將電子郵件發送到我的垃圾郵件箱。

如何避免使用php mail()函數的spambox?

我已經在搜索和計算器,但serverfault我似乎無法找到合適的解決方案....

這是我使用的代碼。

<?php 
if (isset($_POST['email']) 
&& isset($_POST['name']) 
&& isset($_POST['message']) 
) { 

$admin_email = "[email protected]"; 
$name = htmlspecialchars($_POST['name']); 
$phone = htmlspecialchars($_POST['phone']); 
$email = htmlspecialchars($_POST['email']); 
$subject = "Contact"; 
$comment = nl2br(htmlspecialchars($_POST['message'])); 
$to = $admin_email; 

$headers = "From: " . $email . "\r\n"; 
$headers .= "Reply-To: " . $email . "\r\n"; 
$headers .= "Return-Path: The Sender <" . $admin_email . ">\r\n"; 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=UTF-8\r\n"; 

$message .= "<html> 
<body style='margin: 0; padding: 0; font-family: Roboto Slab;'> 
<table cellpadding='0' cellspacing='0' width='100%'> 
<tr> 
<td> 
<table style='border: 1px solid #c7c5c5;' align='center' cellpadding='0'   cellspacing='0' width='600' style='border-collapse: collapse;'> 
    <tr height='301'> 
    <td align='center' bgcolor='#ffffff' style='padding: 0 0 0 0;'> 
     <img src='myimage' alt='Contact' width='100%' height='100%' style='display: block;' /> 
    </td> 
    </tr> 
    <tr> 
    <td bgcolor='#eee' style='padding: 40px 30px 40px 30px; background-color: #eee;'> 
     <table cellpadding='0' cellspacing='0' width='100%'> 
     <tr> 
     <td> 
      <h1 style='font-family: Roboto Slab;'>Contactinformation</h1> 
     </td> 
     </tr> 
     <tr> 
     <td style='padding: 20px 0 30px 0; font-family: Roboto Slab;'> 
     <b>From:</b> " . $naam . " <br/> 
     <b>E-mail:</b> " . $email . " <br/> 
     <b>Phone:</b> " . $phone . " 
     </td> 
     </tr> 
     <tr> 
     <td> 
      <h1 style='font-family: Roboto Slab;'>Message</h1> 
     </td> 
     </tr> 
      <tr> 
       <td style='padding: 20px 0 30px 0; font-family: Roboto Slab;'> 
       " . $comment . " 
       </td> 
      </tr> 
     </table> 
    </td> 
    </tr> 
    <tr> 
    <td bgcolor='#33333' style='padding: 30px 30px 30px 30px; background-color: #333;'> 
     <table cellpadding='0' cellspacing='0' width='100%'> 
     <td style='color: #fed136; font-family: Roboto Slab;' width='70%'> 
      Copyright &reg; 
      <a style='color: #fed136; font-family: Roboto Slab;' href=''></a> " . $thisyear . "<br/> 
     </td> 
     <td align='right'> 
      <table border='0' cellpadding='0' cellspacing='0'> 
      <tr> 
      <td> 
      <a style='color: #fed136; font-family: Roboto Slab;' href=''> 

      </a> 
      </td> 
      </tr> 
      </table> 
     </td> 
     </table> 
    </td> 
    </tr> 
</table> 
    </td> 
    </tr> 
    </table> 
     </body> 
     </html>"; 
     mail($to, $subject, $message, $headers); 
    } 
    ?> 

非常感謝提前!

+0

你是Google嗎?有很多關於此的帖子。編輯:我想你是。那麼,你看起來不夠遠。 –

回答

0

某些郵件客戶端如gmail有一定的規則將郵件標記爲垃圾郵件。如果郵件主題或正文包含
免費/促銷/優惠/等。並且它不是來自可信發件人,它將被標記爲垃圾郵件。此外,這些郵件客戶端將某些發件人列入黑名單,並將其列入垃圾郵件框。 它也發生在很多大公司。