PHP邮件功能正在Gmail的SPAM文件夹中发送电子邮件,如何摆脱它?
我正在使用此代码:
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
它将电子邮件发送到我的 gmail 的垃圾邮件文件夹。
提出任何解决方案。
我不想使用任何 PEAR MAIL 类型的方式发送电子邮件或不想要求和包含任何文件。
此函数无需包含/需要任何额外的 php 文件即可工作。
i am using this code :
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
it sends email to my gmail's SPAM folder .
Suggest any solution .
i dont want to use any PEAR MAIL type way to send email or dont want to require and include any file.
This functions works without including/requiring any additional php file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该使用 PHP 手册中的正确标头
You should use proper header like this from PHP manual
Gmail 垃圾邮件过滤器有很多部分可以确定邮件是否为垃圾邮件。您可以首先查看您的域的 SPF 记录。尽可能避免在电子邮件中使用销售语言、HTML 和颜色。
Google 还提供了一个古老但有趣的视频,介绍了垃圾邮件过滤的工作原理。
The Gmail spam filter has lots of parts to it which determine the spamminess of mail. You could start by seeing the SPF record for your domain. Avoid using sales language, HTML and colours where possible in your email.
There's also an old but fun video from Google about how their spam filtering works.
一切都在标题中。我不知道 GMail 内部是如何工作的,但我在我的项目中发现设置 Reply-To 可以 Content-Type 标头似乎可以解决此问题。
有关执行此操作的示例,请参阅 PHP mail() 文档。
(注意:我有一个 PHP 调查问卷/响应系统,可以设置这些标头,并且电子邮件可以正确发送到 GMail、Hotmail 和 Yahoo! Mail)。
It's all in the headers. I don't know how GMail works internally, but I've found on my projects that setting Reply-To can Content-Type headers seems to fix this.
See PHP mail() docs for an example of doing this.
(Note: I've got a PHP questionnaire/response system that sets these headers and the e-mails come through correctly to GMail, Hotmail and Yahoo! Mail).