Kue*_*uen 0 php email sendmail
我正在开发一个必须发送电子邮件的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);
Run Code Online (Sandbox Code Playgroud)
在我放的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
Run Code Online (Sandbox Code Playgroud)
有谁知道这意味着什么?
第一步是弄清楚sendmail的安装位置.一旦你知道了这条路径,就进入你的php.ini.您正在寻找sendmail_path设置.适当地设置它.
如果路径设置正确,则mail()应该返回正确调用的结果true.(请注意,返回值只会让您知道邮件是否已传递给sendmail [或Windows中的SMTP].它不能保证电子邮件已经用完,或者sendmail配置正确.)如果是正在返回true,你仍然没有收到电子邮件,然后检查你的sendmail配置.
| 归档时间: |
|
| 查看次数: |
17903 次 |
| 最近记录: |