Zend_Mail 发送的电子邮件被视为垃圾邮件

发布于 2024-09-18 22:27:14 字数 738 浏览 8 评论 0原文

请告诉我我做错了什么。我正在使用 Zend_Mail 类发送电子邮件,如下所示:

$message = <<<STR
You have a new invoice!

Sign in to your clientarea to see it.

Best regards,

Company name
STR;

$mail = new Zend_Mail();
$mail->setBodyText($message);
$mail->setFrom('[email protected]', 'Company.com');
$mail->addTo('[email protected]', 'Client Name');
$mail->setSubject('You have a new invoice!');
$mail->send();

但它被作为垃圾邮件接收。我的服务器上还有其他应用程序,例如 Webmin,它们发送的电子邮件不会被视为垃圾邮件。

Please tell me what I am doing wrong. I am sending an email using the Zend_Mail class like this:

$message = <<<STR
You have a new invoice!

Sign in to your clientarea to see it.

Best regards,

Company name
STR;

$mail = new Zend_Mail();
$mail->setBodyText($message);
$mail->setFrom('[email protected]', 'Company.com');
$mail->addTo('[email protected]', 'Client Name');
$mail->setSubject('You have a new invoice!');
$mail->send();

It is received as a spam though. There are other applications such as Webmin on my server and emails they send is not treated as SPAM.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

鲜肉鲜肉永远不皱 2024-09-25 22:27:14

我通过添加这些行解决了这个问题:

$mail->setReplyTo('[email protected]', 'Company');
$mail->addHeader('MIME-Version', '1.0');
$mail->addHeader('Content-Transfer-Encoding', '8bit');
$mail->addHeader('X-Mailer:', 'PHP/'.phpversion());

关键行似乎是添加 Reply-To 标头。如果没有它,它总是会进入垃圾邮件。一旦我设置了回复标题,电子邮件客户端就不再将其视为垃圾邮件。

I have solved this by adding these lines:

$mail->setReplyTo('[email protected]', 'Company');
$mail->addHeader('MIME-Version', '1.0');
$mail->addHeader('Content-Transfer-Encoding', '8bit');
$mail->addHeader('X-Mailer:', 'PHP/'.phpversion());

The critical line seems to be adding Reply-To header. Without that it would always go to SPAM. Once I set the Reply-To header email clients stopped treating it as spam.

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