I am trying to send plain/text email to gmail using the following PHP code:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "example@gmail.com";
$email_subject = "Sree Vizag Marketing-Tiles Enquiry";
$first_name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$phone = $_POST['phone']; // not required
$comments = $_POST['comments']; // required
$email_message .= "First Name: ".$first_name."\
\
";
$email_message .= "Email: ".$email_from."\
\
";
$email_message .= "Telephone: ".$phone."\
\
";
$email_message .= "Comments: ".$comments."\
";
//create email headers
$headers = "From: $email_from";
'Reply-To: '.$email_from."\\r\
" .
'X-Mailer: PHP/' . phpversion();
$mail_sent = @mail($email_to, $email_subject, $email_message, $headers);
echo $mail_sent ? "Mail sent" : "Mail failed";
}
?>
Using this code the email does not show up in the gmail inbox.Any kind help will be appreciated.
srinivas.