
PK 
<?php
ob_start();
session_start();
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/SMTP.php';
$response = ['success' => false];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$mobile = trim($_POST['mobile'] ?? '');
$subject = trim($_POST['subject'] ?? '');
$message = trim($_POST['message'] ?? '');
$recaptchaResponse = $_POST['g-recaptcha-response'] ?? '';
// Validate reCAPTCHA
$secretKey = '6LcGGaEqAAAAAHgN_Zya562hnBy99_8juZhaQdr1'; // Replace with your reCAPTCHA secret key
$recaptchaUrl = 'https://www.google.com/recaptcha/api/siteverify';
$recaptchaValidation = file_get_contents($recaptchaUrl . '?secret=' . $secretKey . '&response=' . $recaptchaResponse);
$recaptchaResult = json_decode($recaptchaValidation, true);
if (!$recaptchaResult['success']) {
$response['error'] = 'Invalid reCAPTCHA. Please try again.';
echo json_encode($response);
exit;
}
if ($name && $email && $mobile && $subject && $message) {
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'indusinfotek.vinay@gmail.com'; // Replace with your email
$mail->Password = 'cohzyuhndznlijbt'; // Replace with your app password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
$mail->setFrom('indusinfotek.vinay@gmail.com');
$mail->addAddress('parmeshbali.advocate@gmail.com'); // Admin email
//$mail->addAddress('indusinfotek.vinay@gmail.com'); // Admin email
$mail->isHTML(true);
$mail->Subject = 'Contact Form Submission: ';
$mail->Body = "
<p>You have received a new inquiry from your website www.parmeshbaliadvocate.com:</p>
<p><strong>Name:</strong> $name</p>
<p><strong>Email:</strong> $email</p>
<p><strong>Mobile:</strong> $mobile</p>
<p><strong>Subject:</strong> $subject</p>
<p><strong>Message:</strong></p>
<p>$message</p>
";
$mail->send();
$response['success'] = true;
} catch (Exception $e) {
$response['error'] = 'Mailer Error: ' . $mail->ErrorInfo;
}
} else {
$response['error'] = 'All fields are required.';
}
}
echo json_encode($response);
?>


PK 99