What errors if any are reported by PHP? You might need to crank up the error reporting level to report everything, and log any errors to an error log file
Actually When I click On Submit Button I get A Message Mail Sent Successfuly But Mail Never Reaches The Email Id Mentioned In Php Script.Thats the Error.
Maybe Some Code I Am Going Wrong In Php Script.Please I Would Be Grateful To You If You Help Me Sorting This Out.
Yes, your mail() function should only have 4 bits in it, like so:
mail($to,$subject,$message,$headers);
So $to is the email to whom the data is being sent, the $subject is the subject line of the email, the $message is what appears in the body of the email, and the $headers is what you already have.
Normally your $message variable would be composed of various bits. E.g.
Tried This Still Mail Not Reaching With Those Messages of mailsent function on clicking submit button Other Than success Message In HTML Form.I Feel Something Is Missing Still.So Mail not Reaching The Destination I Need.
Hehe, are you dislexic? You need to keep the order shown above (and which you had in your original post.) Maybe there are other issues, but you need to get this bit right.
I’ve just noticed that you declare two different content types:
I Added $headers .= ' To: Prajwal <*********@gmail.com>'. "\r\n"; but Never Worked How To Send To Many In General This Is Somehwere I am going Wrong I Feel.
<?php
if(isset($_POST['submit']))
{
$to = '*********@gmail.com';
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['contactno'];
$subject = 'Enquiry';
$comment = $_POST['msg'];
$message .= '<html><body>';
$message .= '<table>';
$message .= '<tr><td><strong> Name:</strong> </td><td>' . $name . "</td></tr>";
$message .= '<tr><td><strong>Email:</strong> </td><td>' . $email . "</td></tr>";
$message .= '<tr><td><strong>Mobile Number:</strong> </td><td>' . $phone . "</td></tr>";
$message .= '<tr><td><strong>Message:</strong> </td><td>' . $comment . "</td></tr>";
$message .= '</table>';
$message .= '</body></html>';
$headers .= 'To: Prajwal <*********@gmail.com>'. "\r\n";
$headers .= 'From: Rithesh <*******************@gmail.com>' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'X-Mailer: PHP/'. phpversion();
$headers .= 'Content-Type: text/html; charset=iso-8859-1'. "\r\n";
$mailsent = mail($to,$subject,$message,$headers);
if($mailsent)
{
echo '<div id="success" class="success box">
Thank you. We have received your message and will contact you back shortly.
</div>';
}
else
{
echo '<div id="error" class="error box">
Something went wrong. Please contact us via email or phone. We truly apologize for the inconvenience.
</div>';
}
}
?>
Tried As You Said But None Worked This Is The Finalised Script I am Using But Not Getting Results.Lol Seems Like It Will Be A Great Fix To Me Trying Hard Without PHP Knowledge.
<?php
if(isset($_POST['submit']))
{
$to = '*********@gmail.com';
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['contactno'];
$subject = 'Enquiry';
$comment = $_POST['msg'];
$message .= '<html><body>';
$message .= '<table>';
$message .= '<tr><td><strong> Name:</strong> </td><td>' . $name . "</td></tr>";
$message .= '<tr><td><strong>Email:</strong> </td><td>' . $email . "</td></tr>";
$message .= '<tr><td><strong>Mobile Number:</strong> </td><td>' . $phone . "</td></tr>";
$message .= '<tr><td><strong>Message:</strong> </td><td>' . $comment . "</td></tr>";
$message .= '</table>';
$message .= '</body></html>';
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=iso-8859-1'. "\r\n";
$headers .= 'From: Rithesh <*******************@gmail.com>' . "\r\n";
$headers .= 'X-Mailer: PHP/'. phpversion();
$mailsent = mail($to,$subject,$message,$headers);
if($mailsent)
{
echo '<div id="success" class="success box">
Thank you. We have received your message and will contact you back shortly.
</div>';
}
else
{
echo '<div id="error" class="error box">
Something went wrong. Please contact us via email or phone. We truly apologize for the inconvenience.
</div>';
}
}
?>
Some web hosting providers have the mail() function disabled and you have to use SMTP calls instead - could this be the reason your mail() call isn’t working?