问题
Why? I can send via mail() in PHP but I can't send via PHPMailer using IsSendmail()
回答1:
Are you sure the path /usr/sbin/sendmail
is correct?
If yes, check also the permissions for sendmail are set correctly.
回答2:
I've had the same error. Solved it by commenting/deleting this:
$mail->IsSendmail();
Now it works correctly. I can send mails, and I receive them in my inbox.
回答3:
I had this same issue. Spent almost an hour checking logs, checking sendmail paths and testing php mail() and sendmail from command line to no avail. And finally all I did was restarted Apache using apachectl -k graceful
and the universe was healed.
回答4:
For me it's working with $mail->IsSMTP()
.
IsSendmail()
is looking for sendmail.
回答5:
I agree with the bloc above. The default mail() function is enabled on all servers (i believe). In my case I was able to send basic html using the simple mail() function but when I used PHPMailer to do that I had that error.
So I removed the part where it checks i.e. IsSendMail() and all was fine. Now more exception thrown.
For people who want to use SMTP. First create an email account on your sever and then define its parameter in your code.
Cheers,
Talha
回答6:
Removing IsSendmail() just created another error for me, in the end the host provider had to remove safemode on the PHP settings. It then worked
Edit By David Burdess
SafeMode should not be set on a live server! For example sites that run on Joomla or other CMS solutions it should not be enabled except in a testing environment
回答7:
PHP with enabled safe_mode
on shared servers (and probably on others too) will fail to open /usr/sbin/sendmail
(PHPMailer uses popen
)
来源:https://stackoverflow.com/questions/4393724/phpmailer-reports-could-not-execute-usr-sbin-sendmail