This question already has an answer here:
My website uses a normal html form and php code to send an email. The email function works perfectly fine when I try it using a laptop browser. However, if I attempt to do the same from my mobile's browser, no mail is being sent. Could someone give me a reason for this and/or help me fix the problem?
Here's the code:-
<?php
if(isset($_POST['submit']))
{
$to = "sample@email.com"; // this is receiver's Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$subject = "Contact Form submission";
$message = "Name:".$name . "\n" . "Email:" .$from. "\n" . "Message: " . $_POST['message'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
$alert_message = "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
echo "<script type='text/javascript'>alert('$alert_message');</script>";
}
?>