PHP Mail() Works from Command Line But Not Apache

PHP mail() works from command line but not apache

I found the problem. SELinux was preventing apache from being able to use sendmail. To diagnose, I used

$ sestatus -b | grep sendmail  
httpd_can_sendmail off

Then to actually fix the problem:

$ restorecon /usr/sbin/sendmail
$ setsebool -P httpd_can_sendmail 1

Read more about it here.

Using PHP's mail() works from command line, not from Apache, any idea why?

Okay, I found the solution, for whatever reason the sendmail path in php.ini has to look like this for PHP's mail to work through Apache on OS X Yosemite:

sendmail_path = "env -i /usr/sbin/sendmail -t -i"

Thanks to everyone who tried to find an answer.

PHP can send email from command line but not browser

Apparently new-server-owner was smart enough to not let apache run as root. All fixed now. Thanks @EdHeal

PHP mail() function sends mail from php5 cli but not when the script is run by a browser

Apache and the CLI seem to use different configurations in your setup.

Compare the configuration in /etc/php5/cli/php.ini with your Apache's php.ini. Probably something is not working with the sendmail configuration for Apache's PHP and the CLI configuration is right.



Related Topics



Leave a reply



Submit