My mail function is not working in xammp although I have configured all things in "php.ini" and "sendmail.ini". And I am not getting any type of error message.
<!-----------php.ini---------->
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = pkkulhari2021@gmail.com
sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"
<!-------------sendmail.ini----------->
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=pkkulhari2021@gmail.com
auth_password=*******
force_sender=pkkulhari2021@gmail.com
smtp_ssl=tls
<!------------contact.php----------->
<form action="" method='post'>
<input type="text" name="name" id="" placeholder='Name'><br>
<input type="email" name="email" id="" placeholder='E-Mail'><br>
<textarea name="message" id="" cols="30" rows="10" placeholder='Message'></textarea><br>
<input type="submit" name="submit" value="Send">
</form>
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "praveen.kulhari07@gmail.com";
$subject = "Contact Form";
$headers = "From: $email";
$body = "Sender Name: $name \r\n Message: $message";
$send_mail = mail($to, $subject, $body, $headers);
if ($send_mail) {
echo "Successfull.";
} else {
echo "Something went wrong!";
}
}
?>
I tried this same contact page on my hosting and It works fine there. But why is It not working on xammp?