Sendmail 不适用于 PHP

Sendmail doesn't work on PHP

我在 CentOs/nginx 服务器上设置 sendmail 时遇到了很大的问题。 如果我使用命令行 sendmail 确实有效,但如果我使用 phpmailer,它只会显示 "could not istantiate mail function".

我什至尝试过使用传统的单行命令:

   mail('mail@mail.com', 'test', 'you done that','From: postmaster@mydomain.com');

但它没有 return 错误或任何错误。

Phpinfo() 确认正确设置了以下值:

sendmail_from   postmaster@mydomain.com
sendmail_path   /usr/sbin/sendmail -t -i

问题出在哪里?非常感谢

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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

请试试这个例子。