I have installed sendmail
on my Apache server (Ubuntu)
Everything seems to work find except an email is not beeing sent while using php mail();
I get an error on the Apache errorlog saying:
/usr/sbin/sendmail: no recipients found
This is the way I'm using the function:
$user_email = "myemail@gmail.com";
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= 'To: ' . $user_email . "
";
$headers .= 'From: Mydomain <do-not-reply@mydomain.com>' . "
";
mail($user_email,"subject","message",$headers);
$user_email = myemail@gmail.com
should be
$user_email = "myemail@gmail.com";
What caused the error is that you had (in your original posted code):
$user_email = myemail@gmail.com
Both encompassing quotation marks and ending semi-colon were not present.
Here is the correct and proper form:
$user_email = "myemail@gmail.com";
It can also be written like this, using single quotes:
$user_email = 'myemail@gmail.com';
As taken from the mail()
function on PHP.net
I installed ssmtp on my ubuntu/apache2/php set up, and I found I had to set the sendmail parameters in php.ini
mail.force_extra_parameters = -t
As I understand it, ssmtp emulates a sendmail set up, and the -t parameter forces the mta to scan the incoming mail (from PHP) for a 'To:' header.
As a point of note, I also had to change the symbolic link that the ssmtp install created to include the full path of the bin (ln -s /usr/sbin/ssmtp sendmail), so that the file could be found by apache