如何避免我从 PHP mail() 发送的邮件被标记为垃圾邮件?
我使用以下方式发送注册电子邮件:
$subject = 'subject is here';
$message_raw = 'e-mail text';
$message = base64_encode($message_raw);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: base64' . "\r\n";
$headers .= 'From: papa.sk <[email protected]>' . "\r\n";
$sendit = mail($to, $subject, $message, $headers);
对于某些人来说,电子邮件被放入垃圾邮件文件夹(gmail 中也是如此)。
在 /etc/postfix/main.cf 中,我有这样的内容:
myorigin = /etc/mailname
smtpd_banner = papa1.vps.websupport.sk ESMTP
不确定是否应该更改上述内容。
I'm using the following to send registration e-mails:
$subject = 'subject is here';
$message_raw = 'e-mail text';
$message = base64_encode($message_raw);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: base64' . "\r\n";
$headers .= 'From: papa.sk <[email protected]>' . "\r\n";
$sendit = mail($to, $subject, $message, $headers);
For some people the e-mails are put into the spam folder (in gmail too).
In /etc/postfix/main.cf I have this:
myorigin = /etc/mailname
smtpd_banner = papa1.vps.websupport.sk ESMTP
Not sure whether I should change the above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的服务器可能需要反向 DNS 记录。
如果无法查找主机名,许多邮件服务器会认为从主机发送的邮件是垃圾邮件。即
nslookup papa.sk
应返回 IP 地址,而nslookup
应返回 papa.sk。you may need a reverse dns record for your server.
many mail servers considers that mails sent from a host are spam if the hostname cannot be looked up. that is
nslookup papa.sk
should return an ip address, andnslookup <ip address>
should return papa.sk.php
mail()
函数与您的电子邮件被标记为垃圾邮件无关。另一端发生电子邮件被标记为垃圾邮件的情况。您无法使用
mail()
对进程产生太大影响 - 因为它是另一端。电子邮件被标记为垃圾邮件的原因可能有数千种,只要您不知道电子邮件被标记为垃圾邮件的具体原因,您就无能为力。
顺便说一句,有一整个行业就是以此为生的。
The php
mail()
function has nothing to-do with your emails being marked as spam.That an email is being marked as spam happens on the other end. You can not influence the process much with
mail()
- as it's the other end.There can be thousand of reasons why an email is being marked as spam, and as long as you don't know the concrete reason why your email is being marked as spam, you can do nothing against that.
There is a whole industry which makes a living of that btw.