I want to send an email on my gmail on submission of form. Success message-"Email send successfully is displayed" but I did not receive any email on my gmail-
Following is the code that I used to send email on form submission.
if(isset($_POST["submit"])){
//Checking for blank Fields..
if($_POST["vname"]==""||$_POST["vemail"]==""||$_POST["sub"]==""||$_POST["msg"]==""){
echo "Fill All Fields..";
}else{
// Check if the "Sender's Email" input field is filled out
$email=$_POST['vemail'];
// Sanitize e-mail address
$email =filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate e-mail address
$email= filter_var($email, FILTER_VALIDATE_EMAIL);
if (!$email){
echo "Invalid Sender's Email";
}
else{
$subject = $_POST['sub'];
$message = $_POST['msg'];
$headers = 'From:'. $email2 . "\r\n"; // Sender's Email
$headers .= 'Cc:'. $email2 . "\r\n"; // Carbon copy to Sender
// message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// Send mail by PHP Mail Function
mail("preetkaurpaik@gmail.com", $subject, $message, $headers);
echo "Your mail has been sent successfuly ! Thank you for your feedback";
}
}
}
?>