
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 sendMail2($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 = 'pojdvqsuozvohirf'; // Replace with your password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
$mail->setFrom('info@studiosdws.com', 'Studio DWS');
$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') {
$username = !empty($_POST['username']) ? trim($_POST['username']) : '';
$email = !empty($_POST['email']) ? trim($_POST['email']) : '';
$message = !empty($_POST['message']) ? trim($_POST['message']) : '';
$recaptchaResponse = !empty($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : '';
// Validate reCAPTCHA
$secretKey = '6Lc7aIMqAAAAAOt8e6MyUWxbjxijZN_OpqCDbH03';
$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 ($username && $email && $message) {
$function = new FUNCTIONS();
$subject = 'Contact';
$to = 'samiya.pathak@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 Studio DWS.</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;">'.$username.'</td>
</tr>
<tr>
<td width="200px;">Email Address</td>
<td width="20px;">:</td>
<td width="380px;">'.$email.'</td>
</tr>
<tr>
<td width="200px;">Message</td>
<td width="20px;">:</td>
<td width="380px;">'.$message.'</td>
</tr>
</table>';
$result = $function->sendMail2($to, $subject, $messagebody);
$response = $result;
} else {
$response['error'] = 'All fields are required.';
}
}
echo json_encode($response);
?>


PK 99