EDIT: Someone marked this as a duplicate question but after reviewing the other thread (And following every step on John Conde answer) but I'm still unable to get the mail() function to work. I would very much appreicate some help, not just redirecting me to someone else's thread.....
I'm using the PHP function Mail() to send an email to my boss and myself after someone has filled out our contact form. I've used the same code (only changed the subject and header redirect location) in 2 other contact forms on our site and it works fine for both of those contact forms, but for some reason this form wont work. Here's my code relating to the email (This isn't my entire php script though I can post it if it will help. Also if you see "removed" I removed the real content for security reasons).
$email_from = $Email;
$email_subject = "3D Part Finishing Contact Form";
$email_body = '<html><body>';
$email_body .= '<table border="1" cellpadding="15">';
$email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Name:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $FName . " " . $LName . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Company:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Company . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Email Address:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $Email . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Secondary Email Address:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Email2 . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Street:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $Street . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>City:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $City . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>State:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $State . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Country:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Country . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Zipcode:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $Zipcode . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Phone:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Phone1 . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66CCFF' width='150px'><strong>Fax:</strong> </td><td bgcolor='#66CCFF' width='400px'>" . $Fax . "</td></tr>";
$email_body .= "<tr><td bgcolor='#66FFFF' width='150px'><strong>Message:</strong> </td><td bgcolor='#66FFFF' width='400px'>" . $Message . "</td></tr>";
$email_body .= "</table>";
$email_body .= "</body></html>";
$rbailey = "removed";
$info = "removed";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $Email \r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
if(mail($rbailey,$email_subject,$email_body,$headers)){
echo " Email sent to Rbailey";
} else {
echo " Email not sent to Rbailey";
}
if(mail($info,$email_subject,$email_body,$headers)){
echo " Email sent to Info";
} else {
echo " Email not sent to Info";
}
header('location:Contact.php');
}
I've verified that when the form is submitted it inserts the data into our database and sends the email (Both mail() functions echo "Email sent to Info/Rbailey"). Although my website says both emails are sent neither email receives the email (yes I've checked the junk an spam folders lol)
thanks in advance for any help!