Problem with sending email using php mail() function

Problem with sending email using php mail() function

Recently i am working with the form and that form goes in the email, i found that email is not going even everything is coded perfectly. after doing all the research i knew the problem, why php mail() function not working and email not sent.

when we send any email then we set headers to send the email. if you set the from email id in the header then please be careful on this because some server do not allow gmail, yahoo, hotmail, msm, aim, aol etc.. in the from email id, you need to set the from email id which is sever email id.

Suppose your domain is www.freelancephpdevelopment.com and if you use below code in headers then its not work.

 
<?php
$headers = "From: pinkeshpatel2915@gmail.com\r\n";
$headers .= "Reply-To: pinkeshpatel2915@gmail.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
?>

Above code is correct but then also if its not send the email that means your server do not allow gmail, yahoo, hotmail, msm, aim, aol etc..

if you use below code then its work.

 
<?php
$headers = "From: pinkeshpatel2915@freelancephpdevelopment.com\r\n";
$headers .= "Reply-To: pinkeshpatel2915@freelancephpdevelopment.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
?>

I Hope this is clear and you get the solution as well. Enjoy……..