EVOLUTION-NINJA
Edit File: send_mail.php
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require __DIR__ . '/../vendor/autoload.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $name = htmlspecialchars($_POST['name']); $phone = htmlspecialchars($_POST['phone']); $email = htmlspecialchars($_POST['email']); $message = htmlspecialchars($_POST['message']); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { die("Invalid email format."); } $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'enquiry09.gta@gmail.com'; $mail->Password = 'phiw kvrj kofj jfid'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; $mail->setFrom('enquiry09.gta@gmail.com', 'Enquiry'); $mail->addAddress('amcadpatha.1996@gmail.com', 'Amcad'); $mail->isHTML(true); $mail->Subject = 'New Inquiry From Contact Form'; $mail->Body = " <h3>New Inquiry from the Contact Form</h3> <p><strong>Name:</strong> $name</p> <p><strong>Phone:</strong> $phone</p> <p><strong>Email:</strong> $email</p> <p><strong>Message:</strong><br>$message</p> "; $mail->send(); echo "<script> alert('Message sent successfully!'); window.location.href = document.referrer; </script>"; } catch (Exception $e) { // Alert for error and redirect back to the same page echo "<script>alert('Message could not be sent. Error: {$mail->ErrorInfo}'); window.location.href = '" . $_SERVER['PHP_SELF'] . "';</script>"; } exit; }