0

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?

Praveen Kumar
  • 49
  • 1
  • 6
  • You need to configure your xampp and it is answered below [a link](https://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost#:~:text=You%20can%20send%20mail%20from,%3A%5Cxampp%5Csendmail%5Csendmail.) – NIKHIL Jun 10 '20 at 04:27
  • @NIKHIL I have configured all things on xammp, you can see above. But It still not working. – Praveen Kumar Jun 10 '20 at 05:07
  • There's not enough information here. Show what's in your web and mail server logs, show precisely how it's "not working". Hint: the act of doing this will probably tell you what the problem is. – Synchro Jun 10 '20 at 08:01

0 Answers0