I am using PHP 5.4.35-0+deb7u2 on Debian 7.0. I use the following PHP code to send a message.
$to = $emailAddress;
$subject = "Registration";
$message = "Dear " . $firstname . " " . $lastName .",\n\n" .
"Thank you for registering for our program.\n\n" .
"To complete your registration, please confirm your registration using the following activation code.\n\n" .
$randomActivationCode . "\n\n" .
"at the following link.\n\n" . $Link . "\n\n" .
"If you did not register for our program, please accept our apologies and disregard this message\n\n" .
"Have a wonderful day!\nCompany name.\n";
$from = "me@yahoo.com";
$headers = "From:" . $from;
$mailDelivery=mail($to,$subject,$message,$headers);
if ($mailDelivery)
{
?>
<script type="text/javascript">
document.location.href="http://home.com/Prewelcome.php";
</script>
<script type="text/javascript">
alert("Thank you for your interest in our program.\nTo complete your registration, please check your email.");
document.location.href="Subscriptions.php";
</script>
<?php
}
else
{
?>
<script type="text/javascript">
alert("Mail delivery failed");
</script>
<?php
}
I get the alert box "Thank you for your interest in our program.\nTo complete your registration, please check your email." but the email never shows up. (I am using my email address as the recipient.)
I also edited php.ini and made sure that
sendmail_path = /usr/sbin/sendmail
was included and that /usr/sbin/sendmail exists. After doing this, I also restarted apache with
sudo /etc/init.d/apache2 restart
I also did the following test
sendmail me@gmail.com
from the command line and the mail did show up in my mail box.
I also ran
sudo cat /var/log/apache2/error.log
and there were no errors.
However the mail I send from my php file never shows up in my mail box.