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
PHP - Fastest Way to Check Presence of Text in Many Domains (Above 1000)
Php: What Is the Complexity [I.E O(1),O(N)] of the Function 'Count'
How to Check If File Is Ascii or Binary in PHP
Warning: MySQL_Num_Rows() Expects Parameter 1 to Be Resource, Boolean Given
How to Remove an HTML Element Using the Domdocument Class
Codeigniter Redirect -- the Uri You Submitted Has Disallowed Characters
PHP Domdocument Getting Attribute of Tag
Mysqli Insert Error Incorrect Syntax
Read the Longest String from an Array in PHP 5.3
How to Send Email with PDF Attachment Using PHP