php Mail() 函数不起作用

发布于 2024-11-04 13:54:55 字数 1455 浏览 0 评论 0原文

我正在编写一个必须发送电子邮件的 php 脚本。但我的 mail() 函数不起作用。我知道我必须以某种方式配置 php.ini 并且可能是其他东西,但我不知道到底是什么以及如何配置。顺便说一句,我安装了sendmail。 有什么想法吗?多谢。 这是我的代码。

error_reporting(E_ALL); 

$to  = '[email protected]';

$subject = 'subject';

$message = 'text';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n";
$headers .= 'To: user <[email protected]>' . "\r\n";
$headers .= 'From: server <[email protected]>' . "\r\n";

mail($to, $subject, $message, $headers);

在 php.ini 中,我放入 sendmail_path ="/usr/sbin/sendmail"

ps。我使用 Ubuntu

,在我得到的 mail.log 文件中

Apr 29 16:12:05 IT02 sendmail[7660]: My unqualified host name (IT02) unknown; sleeping    for retry 
Apr 29 16:13:05 IT02 sendmail[7660]: unable to qualify my own domain name (IT02) -- using short name 
Apr 29 16:13:05 IT02 sendmail[7660]: p3TED551007660: from=www-data, size=210, class=0, nrcpts=0, msgid=<201104291413.p3TED551007660@IT02>, bodytype=8BITMIME, relay=www-data@localhost 

有人知道这意味着什么吗?

I'm working on a php script which has to send emails. But my mail() function doesn't work. I know that I have to configure somehow php.ini and may be something else but I don't know what exactly and how. I installed sendmail, by the way.
Any ideas? Thanks a lot.
this is my code.

error_reporting(E_ALL); 

$to  = '[email protected]';

$subject = 'subject';

$message = 'text';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n";
$headers .= 'To: user <[email protected]>' . "\r\n";
$headers .= 'From: server <[email protected]>' . "\r\n";

mail($to, $subject, $message, $headers);

in php.ini i put sendmail_path ="/usr/sbin/sendmail"

ps. i Use Ubuntu

guys, in the mail.log file i got

Apr 29 16:12:05 IT02 sendmail[7660]: My unqualified host name (IT02) unknown; sleeping    for retry 
Apr 29 16:13:05 IT02 sendmail[7660]: unable to qualify my own domain name (IT02) -- using short name 
Apr 29 16:13:05 IT02 sendmail[7660]: p3TED551007660: from=www-data, size=210, class=0, nrcpts=0, msgid=<201104291413.p3TED551007660@IT02>, bodytype=8BITMIME, relay=www-data@localhost 

Does anybody know what it means?

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

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

发布评论

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

评论(1

勿挽旧人 2024-11-11 13:54:55

第一步是找出 sendmail 的安装位置。一旦您知道该路径,请进入您的 php.ini。您正在寻找 sendmail_path 设置。适当设置一下。

如果路径设置正确,则正确调用 mail() 的结果应返回 true。 (请注意,返回值仅让您知道邮件是否已传递至 sendmail [或 Windows 中的 SMTP]。它不能保证电子邮件已发出,或 sendmail 配置正确。)返回 true 并且您仍然没有收到电子邮件,然后检查您的 sendmail 配置。

The first step would be to figure out where sendmail is installed. Once you know that path, go into your php.ini. You are looking for the sendmail_path setting. Set it appropriately.

If the path is set correctly, the result from a proper call to mail() should return true. (Note that the return value only lets you know if the message was passed on to sendmail [or SMTP in the case of Windows]. It does not guarantee that the e-mail went out, or that sendmail is configured correctly.) If it is returning true and you still aren't getting e-mail, then check your sendmail configuration.

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