如何避免我从 PHP mail() 发送的邮件被标记为垃圾邮件?

发布于 2024-12-09 02:30:31 字数 755 浏览 2 评论 0原文

我使用以下方式发送注册电子邮件:

$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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

┈┾☆殇 2024-12-16 02:30:31

您的服务器可能需要反向 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, and nslookup <ip address> should return papa.sk.

零崎曲识 2024-12-16 02:30:31

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文