Ad

BACKEND PHP TO SEND EMAIL


 <?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {

  $name = htmlspecialchars($_POST['name']);

  $email = htmlspecialchars($_POST['email']);

  $message = htmlspecialchars($_POST['message']);


  $to = "your-email@example.com";  // ← apna email yahan likhein

  $subject = "New Contact Message from Website";

  $body = "Name: $name\nEmail: $email\n\nMessage:\n$message";


  $headers = "From: $email";


  if (mail($to, $subject, $body, $headers)) {

    echo "Message Sent Successfully!";

  } else {

    echo "Failed to send message. Try again.";

  }

}

?>

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.