如何防止通过PHP邮件()发送的邮件去垃圾邮件? [英] How do I prevent mails sent through PHP mail() from going to spam?

查看:462
本文介绍了如何防止通过PHP邮件()发送的邮件去垃圾邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP的mail()函数发送电子邮件(sendmail进程正在运行)。但是所有的邮件都会被垃圾邮件(在gmail的情况下)。我已经尝试了很多技巧,我发现在网上,但没有一个工作,请告诉我关于任何确定的技巧。

解决方案

您必须添加针头:



示例代码:


  $ headers =From:myplace@example.com\r\\\
;
$ headers。=Reply-To:myplace2@example.com\r
$ headers。=返回路径:myplace@example.com\r\\\
;
$ headers。=CC:sombodyelse@example.com\r
$ headers。=BCC:hidden@example.com\r\\\
;

if(mail($ to,$ subject,$ message,$ headers)){
echo电子邮件已发送!
} else {
echo电子邮件失败!;
}
?>


I am using PHP's mail() function to send emails (sendmail process is running). But all the mails are going to spam (in case of gmail). I have tried many tricks that I found on the net but none is working, please tell me about any sure-shot trick.

解决方案

You must to add a needle headers:

Sample code :

$headers = "From: myplace@example.com\r\n";
$headers .= "Reply-To: myplace2@example.com\r\n";
$headers .= "Return-Path: myplace@example.com\r\n";
$headers .= "CC: sombodyelse@example.com\r\n";
$headers .= "BCC: hidden@example.com\r\n";

if ( mail($to,$subject,$message,$headers) ) {
   echo "The email has been sent!";
   } else {
   echo "The email has failed!";
   }
?> 

这篇关于如何防止通过PHP邮件()发送的邮件去垃圾邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆