【问题标题】:PHP regular mail() function prevent spam [duplicate]PHP常规mail()函数防止垃圾邮件[重复]
【发布时间】:2015-12-22 13:49:06
【问题描述】:

这里是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>");
}
?>

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

编辑:
我知道堆栈中有一些关于此的线程。
但我正在寻找更新的答案。
所以它不是重复

【问题讨论】:

  • 很可能是因为任何人都可以发送这样的“常规”电子邮件,您需要设置服务器以“确认”您是谁/增加一些可信度,查看SPF 和 DKIM

标签: php email spam


【解决方案1】:

这不仅仅是你的脚本,你可以检查你的IP的声誉,你还需要设置SPF记录和DKIM密钥来寻求帮助

https://mxtoolbox.com/

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

你可以检查你的IP的senderscore,因为它会严重影响你的邮件传递

https://www.senderscore.org

【讨论】:

    猜你喜欢
    • 2011-06-05
    • 1970-01-01
    • 2012-12-30
    • 2017-08-31
    • 2023-03-17
    • 2021-01-09
    • 2011-08-21
    • 1970-01-01
    相关资源
    最近更新 更多