如何防止通过PHP邮件()发送的邮件去垃圾邮件? [英] How do I prevent mails sent through PHP mail() from going to spam?
本文介绍了如何防止通过PHP邮件()发送的邮件去垃圾邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
您必须添加针头:
示例代码:
$ 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屋!
查看全文