Mail returns false

I just had the same problem.
After a php upgrade, the mail function always returns false.

I used this little snippet to check it out:

<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
echo 'I am : ' . `whoami`;
$result = mail('[email protected]','Testing 1 2 3','This is a test.');
echo '<hr>Result was: ' . ( $result === FALSE ? 'FALSE' : 'TRUE') . $result;
echo '<hr>';
echo phpinfo();

The solution was setting a value in my php.ini for ‘sendmail_from’ and ‘sendmail_path’.
The correct values in my case were:

sendmail_from = "[email protected]"
sendmail_path = "/usr/sbin/sendmail -t -i"

(I’m using CentOS 5.3 w/ Zend Server CE.)

You could use ini_set() to set the value of ‘sendmail_from’, but the ‘sendmail_path’ var must be setup in your php.ini or http.conf.

Leave a Comment