我的script.php
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$to = 'myemail@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: anotheremail@domain.com' . "\r\n" .
'Reply-To: anotheremail@domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$res = mail($to, $subject, $message, $headers);
var_dump($res);
?>
php.ini essentials
sendmail_path = /usr/sbin/sendmail -t -i
mail.log = /home/myuser/phpmail.log
我如何让它发挥作用?我该怎么做才能调试?
答案 0 :(得分:1)
0)检查sendmail日志文件
1)以同一系统用户身份发送测试消息
#!/bin/sh
/usr/sbin/sendmail -v -t -i <<END
To: myemail@gmail.com
Subject: the subject
From: anotheremail@domain.com
Reply-To: anotheremail@domain.com
hello
END
echo SENDMAIL EXIT CODE: $?
答案 1 :(得分:0)
这终于奏效了
在iptables中为localhost打开端口25,并从php.ini中的sendmail_path中删除“i”
sendmail_path = /usr/sbin/sendmail -t