Didn't getting any mail while it is saying Email set successfully

<?php
 $id=$_REQUEST['id'];
 
	 $email=$_REQUEST['email'];
	
	 $track_num=$_REQUEST['track_no'];
	 $courier_com=$_REQUEST['courier_company'];
	 $track_link=$_REQUEST['track_link'];
	 $c_msg=$_REQUEST['c_msg'];
	 
	 
	 $update_tracking=mysqli_query($con,"Update ".PREFIX."payments SET tracking_number='".$track_num."', shipping_medium='".$courier_com."',
	  other_details='".$c_msg."', shipping_date='".date("Y-m-d H:i:s")."', is_shipped='1' where id='".$id."'");
	  
     if($update_tracking)
     {
	
     $to=$email;
     $subject='Order Shipped';

		$message = '

        <html>

        <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

            <title></title>

        </head>

        <body>

            <div id="email-wrap" >

           <p style="font-size:14px"><strong>Dear Customer,</strong><br><br>Tracking Number:'.$track_num.'<br><br><p>'.$c_msg.'</p>';

		$message .= '<br><br><span>Track your order:-</span><a href="'.$track_link.'">'.$track_link.'</a>';


        $message .='</p><br><br>Thanks..</div>

</body>

        </html>

		';
		
$headers= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=U7F-8' . "\r\n";
$headers .= 'From: <info@test.com>' . "\r\n";

		
if(mail($to,$subject,$message,$headers))
{
	echo '<script>alert("Email Send Successfully!!!")</script>';
}
else
{
	echo '<script>alert("Something Wrong!!!")</script>';
}

}
?>

Check the log of your MTA and eMail client. Debug them while sending.

I did this but no luck.
Is this server side issue?

If you’re actually sending out email as @test.com, your host might be refusing to send it because you dont own test.com. I’d personally avoid using the default mail command and use something more featured like PHPMailer.

Also verify that your web host allows server based mail sending, rather than requiring an external mail handler.

2 Likes

Typo here?

$headers .= 'Content-type: text/html; charset=U7F-8' . "\r\n";

UTF-8, perhaps?

3 Likes

Use an email from the domain you’re running the script from. For example, if it was running on mysite.com, it would be something like webmaster@mysite.com.

Also worth noting… the mail() function returns true when the message was accepted for delivery, not when it was actually sent successfully. See the Return Values section at

https://www.php.net/manual/en/function.mail.php

Depending on how sendmail is configured for PHP on your host, this is almost always going to return true.