I have been struggling to send an email using the mail function in PHP for a while. I want to send 2 separate emails to 2 different email addresses.
$allowHtmlHeader = "MIME-Version: 1.0
";
$allowHtmlHeader .= "Content-Type: text/html; charset=ISO-8859-1
";
$headers = "From: webmaster@xyz.com
Reply-To: webmaster@xyz.com
" . $allowHtmlHeader;
$customerHeaders = "From: a.b.c@gmail.com
Reply-To: a.b.c@gmail.com
" . $allowHtmlHeader;
$subject = "Enquiry";
$message = "Try me...";
$cMessage = "I score better!";
if ($_POST[cEmail] != null)
{
if (mail("a.b@gmail.com", $subject, $cMessage, $cHeaders)) {
echo("Message successfully sent!");
}
else {
echo("Message delivery failed...");
}
if (mail("a.b.c@gmail.com", $subject, $message, $headers)) {
echo("Message successfully sent!");
}
else {
echo("Message delivery failed...");
}
}
Using the above code, i could successfully send emails to a.b@gmail.com . But in all the attempts not a single mail reached a.b.c@gmail.com, though it always successfully reached a.b@gmail.com. I even tried replacing a.b@gmail.com with a.b.c@gmail.com and yet no mail was sent to that email address alone.
Maybe the mail function does not work with emails having more than 1 dot '.' in their names?
Any help would be greatly appreciated!.
SOLVED:
Following Pagerange`s advice, i attempted removing the dots / periods ('.') from the "to" email addresses and emails are sent flawlessly!.