我有一个问题,从我的PHP脚本发送的邮件永远不会发送到我的收件箱,而是垃圾邮件。有关如何将其发送到收件箱的任何帮助。谢谢你们 这是我的代码示例
public function sendMail($name,$email,$message)
{
$this->validateInput($name,"Empty Name","Invalid Name");
$this->validateEmail($email,"Empty Email","Invalid Email");
$this->validateLargeData($message,"Invalid Message","Empty Message","Message Too Short");
if (empty($this->errors))
{
$fromName = $name;
$fromEmail = $email;
$from = "From: $fromName <$fromEmail>\r\n";
$reply = "Reply-To: $fromEmail\r\n";
$mime = "MIME-Version: 1.0\r\n";
$content = "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers = $from.$reply.$mime.$content;
if (mail("support@findit.com.ng","Contact",$message,$headers))
{
echo "<div class='success1'>Thank you $name, we will get back you immediately.</div>";
}
}
else
{
echo "<div class=''>";
echo "</div>";
}
}
修改 请在这里使用我正在使用的标题信息
$fromName = $name;
$fromEmail = $email;
$from = "From: $fromName <$fromEmail>\r\n";
$reply = "Reply-To: $fromEmail\r\n";
$mime = "MIME-Version: 1.0\r\n";
$content = "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mailer = "X-Mailer: PHP's mail() Function";
$headers = $from.$reply.$mime.$content.$mailer;
@cyberomin
答案 0 :(得分:2)
确保标题完整:
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "From: aaa.bbb <aaa@bbb.ccc>\n";
$headers .= "X-Mailer: PHP's mail() Function\n";
mail("xxx@yyy.zzz", "subject","message",$headers);
如果你在共享主机上,可能是你的ip上有黑名单的垃圾邮件发送者。
我可能做的最好的建议是尝试以不同的方式发送电子邮件。例如phpmailer或Swift Mailer。
答案 1 :(得分:0)
如果您在垃圾邮件文件夹中给我们邮件的标题,我们只能给您一个确切的答案,但我认为这是因为您从具有IP范围内包含消费者互联网连接的IP的计算机发送。来自消费者电脑的电子邮件通常是垃圾邮件。