如何避免垃圾箱与PHP邮件()函数
问题描述:
这是我的第一篇文章。是啊!如何避免垃圾箱与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 ®
<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);
}
?>
非常感谢提前!
答
某些邮件客户端如gmail有一定的规则将邮件标记为垃圾邮件。如果邮件主题或正文包含
免费/促销/优惠/等。并且它不是来自可信发件人,它将被标记为垃圾邮件。此外,这些邮件客户端将某些发件人列入黑名单,并将其列入垃圾邮件框。 它也发生在很多大公司。
你是Google吗?有很多关于此的帖子。编辑:我想你是。那么,你看起来不够远。 –