【发布时间】:2011-08-15 12:08:12
【问题描述】:
我正在编写一个必须发送电子邮件的 php 脚本。但是我的 mail() 函数不起作用。我知道我必须以某种方式配置 php.ini 并且可能是别的东西,但我不知道究竟是什么以及如何。顺便说一句,我安装了sendmail。 有任何想法吗?非常感谢。 这是我的代码。
error_reporting(E_ALL);
$to = 'name@gmail.com';
$subject = 'subject';
$message = 'text';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n";
$headers .= 'To: user <user@example.com>' . "\r\n";
$headers .= 'From: server <server@example.com>' . "\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
有人知道是什么意思吗?
【问题讨论】:
-
显示一些代码或至少说出你得到了什么错误。你使用的是 Linux 还是 Windows 的操作系统???
-
@Kuen,您的问题不太清楚。不,可以理解这一点并回答你。改进给出的描述。
-
可以假设服务器是linux,配置指令是相对于sendmail的指令
-
对不起,伙计们,我的错。我用的是 ubuntu,
-
@Kuen,使用该代码和信息编辑您的原始帖子。它不能作为评论阅读。