使用 PHP 发送回复邮件
我正在使用 PHP 向那些向我发送邮件的人发送回复邮件。
我的问题是,当我发送电子邮件时,它位于垃圾邮件文件夹中。 我该怎么做才能正确投递邮件。 我应该怎么办?
我的代码
<?php
$email_id="[email protected]";
$recipient = "@gmail.com"; //Recipient
$mail_body = $message; //Mail body
$subject = "Subject ".$Name.""; //Subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //Optional headerfields
$header .='Content-type: text/plain; charset=utf-8'."\r\n";
mail($recipient, $subject, $mail_body, $header); /mail command :)
?>
I am sending a reply mail using PHP to those who send a mail to me.
My problem is when I send an email, it sits in the spam folder. What do I do in order to deliver mail correctly. What should I do?
My code
<?php
$email_id="[email protected]";
$recipient = "@gmail.com"; //Recipient
$mail_body = $message; //Mail body
$subject = "Subject ".$Name.""; //Subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //Optional headerfields
$header .='Content-type: text/plain; charset=utf-8'."\r\n";
mail($recipient, $subject, $mail_body, $header); /mail command :)
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题不一定出在您的代码中。 一种可能是您服务器的邮件传输代理配置错误 - 我曾经遇到过此问题。 值得检查。
The problem is not necessarily in your code. One possibility is that your server's mail transfer agent is misconfigured - I've experienced this issue once. Worth checking.
确保使用发送电子邮件地址填充 From、Reply-To、Sender、Return-Path 和 Errors-To 标头。 不过,电子邮件被过滤为垃圾邮件的原因有很多——您的 ISP 可能被阻止、邮件内容可能包含被标记的内容等。
Make sure you're populating the From, Reply-To, Sender, Return-Path, and Errors-To headers with the sending e-mail address. There are so many reasons e-mails may be filtered as spam, though - your ISP may be blocked, the contents of the message may contain things that get it flagged, etc.
问题不是来自您的代码。 您可能需要配置您的服务。
为了被大多数电子邮件服务提供商接受,您应该设置一个
DomainKey 或 发件人 ID。
如果您在某个网络上运行此代码,您还应该确保您的 IP 地址 未被列入黑名单专用服务器。
The problem is not coming from your code. You may need to configure your service.
In order to be accepted by most of the email service providers, you should setup a
DomainKey or a Sender Id.
You should also make sure that your IP address is not blacklisted if you are running this code on a dedicated server.