PHP中生成的邮件会发送垃圾邮件

时间:2011-11-10 05:36:05

标签: php email

  

可能重复:
  PHP: How to avoid a system generated e-mail going into spam?
  How to send 100.000 emails weekly?

我使用以下脚本发送邮件

$to  = 'name@test.com' . ', '; 
$to .= 'name2@test.com';

$subject = 'Green apple';

$message = 'Enquiry posted by test ';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";


$headers .= 'From: Green Apple <info@greenappleme.com>' . "\r\n";


if (mail($to, $subject, $message, $headers))
{
    echo "mail send successfully";
}
else  
    echo "mail can't send";

当我将这个脚本用于某些服务器时,邮件就会发送垃圾邮件。但在某些服务器中,它会根据需要进入收件箱。

如何防止电子邮件进入垃圾邮件?

3 个答案:

答案 0 :(得分:1)

要防止电子邮件进入垃圾邮件,请不要使用PHP发送邮件。从服务器发送SMTP,您可以使用PHP连接到SMTP并提交消息。然后,您需要在服务器上设置SPF记录,并将IP地址的来源反转DNS记录。如果您执行这三项操作,那么您将进入白名单,所有电子邮件都将进入收件箱,假设您没有滥用此权限并被列入黑名单。

所以:使用SMTP发送,研究SPF记录并反向DNS。

您将无法执行此操作,除非您的专用服务器具有用于从中发送电子邮件的域的专用IP。

答案 1 :(得分:0)

确保将RETURN PATH设置为mail()函数的可选第5个参数。

if (mail($to, $subject, $message, $headers, '-finfo@greenappleme.com'))

答案 2 :(得分:0)

要将多数邮件发送到标题下方的收件箱中,并且不要在主题行中使用类似关键字的测试

$headers  = "From: My site<noreply@example.com>\r\n";
$headers .= "Reply-To: info@example.com\r\n";
$headers .= "Return-Path: info@example.com\r\n";
$headers .= "X-Mailer: Drupal\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
相关问题