When I send mail to “gatbajrang@gmail.com”, it’s working fine. But when I change email address “gatbajrang@gmail.com” to “bajrang.lal@sunarctechnologies.com” then the mail has not been send, I could not find what is the error here. Both email address are correct. And always printing the message line under if condition.
I have also checked mail in trash,spam etc.
//$email_id = "gatbajrang@gmail.com";
$email_id = "bajrang.lal@sunarctechnologies.com";
$subject = "New Suggestion Posted. Waiting for approval.";
$mail_msg="Hello Admin,<br><br>New Suggestion Posted. Waiting for approval.<br><br>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: Tata NYK <gatbajrang@gmail.com>";
$headers .= "Organization: Tata NYK\r\n";
if(mail($email_id,$subject,$mail_msg))
echo "mail sent to = ".$email_id;
Did you check spams/junk mail? Try using http://swiftmailer.org/ to make things easier. You don’t need to manually add all the headers your own.