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

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

问题描述

我正在使用 PHP 的 mail() 函数发送电子邮件(sendmail 进程正在运行).但是所有的邮件都会变成垃圾邮件(在 gmail 的情况下).我尝试了很多我在网上找到的技巧,但都没有奏效,请告诉我任何可靠的技巧.

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.

推荐答案

必须添加一个针头:

示例代码:

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

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

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

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