php Mail() 函数不起作用
我正在编写一个必须发送电子邮件的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一步是找出 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 returntrue
. (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 returningtrue
and you still aren't getting e-mail, then check your sendmail configuration.