PHPmailer 不发送电子邮件

发布于 2024-12-03 14:16:32 字数 737 浏览 0 评论 0原文

我正在尝试使用 phpmailer 通过 Qmail 服务器发送电子邮件。发送后,我收到消息“meesage was sent”,但没有收到任何消息。这是我的代码:

<?php
require("class.phpmailer.php");
$name = "Purchase Form";
$email_subject = "New Purchase Ticket";
$body = NULL;
foreach ($_REQUEST as $field_name => $value){
if (!empty($value)) $body .= "$field_name = $value\n\r";
}
$mail = new PHPMailer();
$mail->IsQmail();
$mail->FromName = $name;
$mail->AddAddress('*******@*********', 'Purchase Ticket');
$mail->Body = $body;
$mail->IsHTML(false);
$mail->Subject = $email_subject;
if(!$mail->Send())
{  echo "didnt work";
}
else {echo "Message has been sent";}

?>

从命令行我可以输入 mail *****@****.com blah blah< /code> 并成功发送..

Im trying to send email through a Qmail server using phpmailer. After sending, i get the message "meesage was sent" but no message is every received.. Heres my code:

<?php
require("class.phpmailer.php");
$name = "Purchase Form";
$email_subject = "New Purchase Ticket";
$body = NULL;
foreach ($_REQUEST as $field_name => $value){
if (!empty($value)) $body .= "$field_name = $value\n\r";
}
$mail = new PHPMailer();
$mail->IsQmail();
$mail->FromName = $name;
$mail->AddAddress('*******@*********', 'Purchase Ticket');
$mail->Body = $body;
$mail->IsHTML(false);
$mail->Subject = $email_subject;
if(!$mail->Send())
{  echo "didnt work";
}
else {echo "Message has been sent";}

?>

From the command line I can type mail *****@****.com blah blah and it successfully sends..

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

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

发布评论

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

评论(3

你在看孤独的风景 2024-12-10 14:16:35

确保您的服务器允许您以您设置为 FromName 的用户身份发送

Make sure your server allows for you to send as the user that you set as the FromName

风情万种。 2024-12-10 14:16:35

我认为这是一个 CR/LF 问题,这是 php 中的一个已知 Bug 大约四年了,据我所知,到目前为止尚未修复:

http://bugs.php.net/bug.php?id=15841

生成的电子邮件无效(可以找到说明这里:http://cr.yp.to/docs/smtplf.html ),由于使用不符合 RFC 的换行格式。其他 MTA(如 sendmail 和 postfix)会自动纠正此问题; qmail 没有。

您可以:使用 php 编写正确的邮件(lol),或者要求您的 qmail 管理员使用 QmailScanner(http://qmail-scanner.sourceforge.net/ ),它也在做这项工作。

最好的解决方案是卸载 php 并在将来使用 perl duck ;)

I think it is a CR/LF problem, which is a known Bug in php for about four years and -as far as I know- hasn't been fixed up to now:

http://bugs.php.net/bug.php?id=15841

The generated Email isn't valid (explanation can be found here: http://cr.yp.to/docs/smtplf.html ), due to using a non-RFC-conform linebreak-format. Other MTA like sendmail and postfix correct this problem automatically; qmail doesn't.

You can either: write correct mails with php (lol), or ask your qmail-administrator to use the QmailScanner ( http://qmail-scanner.sourceforge.net/ ), which is doing this job too.

The best solution would be to deinstall php and use perl in the future duck ;)

韶华倾负 2024-12-10 14:16:34

检查您的邮件服务器的日志。服务器是否活跃?它正在处理邮件队列吗?它是否尝试发送消息?邮件被退回了吗?消息是否卡在队列中?

仅仅因为 PHPMailer 说它有效并不意味着任何东西实际上都成功了。这意味着 PHPMailer 已成功将电子邮件移交给 SMTP 服务器。在那之后,它就完全脱离了 PHPMailer 的掌控。由于 PHP 方面的所有内容似乎都有效,因此您必须将调查移至流程的下一阶段,即 SMTP 服务器。

Check your mail server's log. Is the server active? Is it handling the mail queue? Did it try sending the message? Did the message bounce? Is the message stuck in the queue?

Just because PHPMailer says it worked doesn't mean anything actually hit the wire. All that means is that PHPMailer successfully handed the email over to the SMTP server. After that, it's utterly out of PHPMailer's hands. Since everything from the PHP side seems to have worked, you'll have to move the investigation down to the next stage of the process, which is the SMTP server.

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