PHP正则邮件()函数可防止垃圾邮件


PHP regular mail() function prevent spam

以下是php-mail()函数代码的简单使用:

<?php
$from    = "From email goes here";
$to      = "To email goes here";
ini_set("display_errors", "On");
ini_set("sendmail_from", $from);
ini_set("SMTP", "localhost");
ini_set("smtp_port", "25");
$subject = "Hello, This is subject";
$message = "<p style='color: green;font-weight: bold;'>Hello World, This is Body</p>";
$headers  = 'MIME-Version: 1.0' . "'r'n";
//$headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
$headers .= 'Content-Type: text/html; Charset=UTF-8' . "'r'n";
$headers .= 'From: Birthday Reminder <' . $from . '>' . "'r'n";
$headers .= 'To: Mary <' . $to . '>' . "'r'n";
$headers .= 'Reply-To: Birthday Reminder <' . $from . '>' . "'r'n";
$headers .= 'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message,$headers))
{
  echo("<p style='color: blue;font-weight: bold;'>Email Sent :D</p>");
} 
else 
{
  echo("<p style='color: red;font-weight: bold;'>Email Message delivery failed...</p>");
}
?>

为什么使用这些代码发送的电子邮件总是进入垃圾邮件文件夹
页眉的顺序可以吗
我应该使用哪些额外的标头来防止垃圾邮件?

编辑:
我知道有一些关于这方面的线索
但我正在寻找最新的答案
因此它不是重复

这不仅仅是关于你的脚本,你可以检查你的IP的信誉,你还应该设置SPF记录和DKIM密钥来帮助

https://mxtoolbox.com/

此在线工具将帮助您正确设置邮件服务器

你可以检查你的IP的发送核心,因为它会严重影响你的邮件的发送

https://www.senderscore.org