I am trying to send an email from php. The mail sends successfully but is never delivered. The code is below..
if(isset($_POST["Referred"])) {
if(isset($_POST["RequestedEmail"])) {
$messagebody="You are invited to join Fasttask. please click on the link below \n http://www.fasttask.net/EmailRequestRedirect.php?User_Id=".$_SESSION['user_id'];
$To=$_POST["RequestedEmail"];
if(mail($To,"Join Fasttask", $messagebody)) {
$query="Update monthlygiveaway set TotalReferrals=TotalReferrals+1 where UserId=?";
$stmt=$mysqli->stmt_init();
$stmt->prepare($query);
$stmt->bind_param('i', $UserId);
$UserId=$_SESSION['user_id'];
$stmt->execute();
echo"Successfully sent mail:".$To;
} else {
echo "Failed to send mail";echo $_SESSION['user_id'];
}
}
}
Everything goes fine.. and the echo message is delivered to callin php function. I checked so the $To
variable does have the address of the recipient. So please help me to trace the issue. :)