
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
require 'PHPMailer/src/Exception.php';
class FUNCTIONS {
public function sendMail($to, $subject, $messagebody) {
$mail = new PHPMailer();
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 password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Use ssl or tls
$mail->Port = 587;
$mail->setFrom('indusinfotek.vinay@gmail.com', 'Amazing World Travel Solutions');
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $messagebody;
if (!$mail->send()) {
return ['success' => false, 'error' => $mail->ErrorInfo];
}
return ['success' => true];
} catch (Exception $e) {
return ['success' => false, 'error' => $e->getMessage()];
}
}
}
$response = ['success' => false];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = !empty($_POST['name']) ? trim($_POST['name']) : '';
$email = !empty($_POST['email']) ? trim($_POST['email']) : '';
$message = !empty($_POST['message']) ? trim($_POST['message']) : '';
$mobile = !empty($_POST['mobile']) ? trim($_POST['mobile']) : '';
$recaptchaResponse = !empty($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : '';
// Validate reCAPTCHA
$secretKey = '6LdQnR4sAAAAABr_A3ZJdc9u_yornUQ2OS_WILOT';
$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 && $message) {
$function = new FUNCTIONS();
$subject = 'Amazing World Travel Solutions Contact form';
$to = 'amazingworldt28@gmail.com';
$messagebody='<table cellpadding="0" cellspacing="0" style="width:600px; margin:0px auto; color:#7b7b7c; vertical-align:middle; font-family:Arial, Helvetica, sans-serif; font-size:16px;">
<tr>
<td style="text-align:center;"><a href="#"><img src="" /></a></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="color:#333;"><strong>Hi, Admin</strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>You have been received a lead from Website Amazing World Travel Solutions.</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" style="width:600px; margin:0px auto; color:#7b7b7c; vertical-align:top; font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:22px;">
<tr>
<td> </td>
</tr>
<tr>
<td style="color:#333;" colspan="3"><strong>Contact Details</strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td width="200px;">Name</td>
<td width="20px;">:</td>
<td width="380px;">'.$name.'</td>
</tr>
<tr>
<td width="200px;">Email Address</td>
<td width="20px;">:</td>
<td width="380px;">'.$email.'</td>
</tr>
<tr>
<td width="200px;">Mobile</td>
<td width="20px;">:</td>
<td width="380px;">'.$mobile.'</td>
</tr>
<tr>
<td width="200px;">Message</td>
<td width="20px;">:</td>
<td width="380px;">'.$message.'</td>
</tr>
</table>';
$result = $function->sendMail($to, $subject, $messagebody);
$response = $result;
} else {
$response['error'] = 'All fields are required.';
}
}
echo json_encode($response);
?>


PK 99