I am new to php and trying to send email to my gmail through form. On clicking submit, i dont see any error on the page but I dont get an email. My from id and to mail id exists and from email id is on the server(making sure not to spam).
<?php
if(isset($_POST['submit'])){
$to = "existingmygamilid@gmail.com";
$subject = "Pickup Request";
$mailContent = $_POST['name'].$_POST['adress'].$_POST['mobile'].$_POST['email'].$_POST['message'];
$message = "
<html>
<head>
<title> Pickup Request</title>
</head>
<body>
<p>Hey!... You got a pickup request.</p>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <existingemail@testdomain.com>' . "\r\n";
mail($to,$subject,$message,$headers);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" class="alt" method="POST">
<div class="row uniform 50%">
<div class="6u 12u$(xsmall)">
<input name="name" placeholder="Name" type="text" />
</div>
<div class="6u$ 12u$(xsmall)">
<input name="address" placeholder="Address" type="text" />
</div>
<div class="6u 12u$(xsmall)">
<input name="mobile" placeholder="Mobile or Landline" type="text" />
</div>
<div class="6u$ 12u$(xsmall)">
<input name="email" placeholder="Email" type="email" />
</div>
<div class="12u$">
<textarea name="message" rows="6"></textarea>
</div>
</div>
<ul class="actions">
<li><input type="submit" value="Send message" /></li>
</ul>
</form>