Viewing File: /home/ubuntu/codegama-ui-revamp/src/index.php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once '../vendor/autoload.php';
require_once 'FormHandler.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$mail = new PHPMailer;
if(empty($_POST['name']) ||
empty($_POST['email']) ||
// empty($_POST['subject']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
$data['success'] = false;
$data['message'] = "Please fill all the fields";
header("Content-Type: application/json; charset=utf-8", true);
return json_encode($data);
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$subject = "Thanks for contacting us";
$message = strip_tags(htmlspecialchars($_POST['message']));
//Disable SMTP debugging.
$mail->SMTPDebug = 0;
//Set PHPMailer to use SMTP.
$mail->isSMTP();
//Set SMTP host name
$mail->Host = "smtp.gmail.com";
//Set this to true if SMTP host requires authentication to send email
//Provide username and password
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "codegamacontact@gmail.com";
$mail->Password = "irdpdcvutxcwopjf";
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "ssl";
//Set TCP port to connect to
$mail->Port = 465;
//Recipients
$mail->setFrom($_POST['email'], 'Customer Contact');
$mail->addAddress($_POST['email'], $_POST['name']); //Add a recipient
$mail->addReplyTo('hrsupport@codegama.com', "Customer Contact");
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = "Thanks for Contacting Us !! Our Sales Person Will Contact you Soon";
$mail->AltBody = "This is the plain text version of the email content";
$test = $mail->send();
if($mail->send()){
$mail->ClearAddresses();
$data['success'] = true;
$data['message'] = "Mail sent";
header("Content-Type: application/json; charset=utf-8", true);
// echo json_encode($data);
} else {
$data['success'] = false;
$data['message'] = "Mail Failed";
header("Content-Type: application/json; charset=utf-8", true);
// echo json_encode($data);
}
// $data['success'] = true;
// $data['message'] = "Mail sent";
// header('Content-type: application/json');
// OUR SUPPORT
$owner_mail = new PHPMailer;
//Disable SMTP debugging.
$owner_mail->SMTPDebug = 0;
$owner_mail->SingleTo = true;
//Set PHPMailer to use SMTP.
$owner_mail->isSMTP();
//Set SMTP host name
$owner_mail->Host = "smtp.gmail.com";
//Set this to true if SMTP host requires authentication to send email
//Provide username and password
$owner_mail->SMTPAuth = true;
$owner_mail->Username = "codegamacontact@gmail.com";
$owner_mail->Password = "irdpdcvutxcwopjf";
//If SMTP requires TLS encryption then set it
$owner_mail->SMTPSecure = "ssl";
//Set TCP port to connect to
$owner_mail->Port = 587;
$owner_mail->setFrom($email_address, $name);
$owner_mail->addReplyTo($email_address, $name);
// $mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$owner_mail->addAddress('hrsupport@codegama.com', "Contact");
$owner_mail->AddBCC('mail@aravinth.net', 'Aravinth Ramesh');
// $owner_mail->AddCC('vithya@codegama.com', 'Vithya R');
$owner_mail->isHTML(true);
$owner_mail->Subject = "Codegama - Contact Form Submission " . $name;
$owner_mail->Body = "Hello " . ',<br><br>';
$owner_mail->Body .= "Name: " . $name . '<br><br>';
$owner_mail->Body .= "Email: " . $email_address . '<br><br>';
$owner_mail->Body .= "Interest: ". '<br><ul>';
foreach($_POST['interest'] as $interest){
$owner_mail->Body .= '<li>'. $interest .'</li>';
}
$owner_mail->Body .= '</ul>';
if ($message) {
$owner_mail->Body .= "Message: " . '<br><br>';
$owner_mail->Body .= $message . '.<br><br>';
}
$owner_mail->AltBody = "Name: " . $name . ", Email:" . $email_address . ", message:" . $message;
// $owner_email_send = $owner_mail->send();
if ($owner_mail->send()) {
$owner_mail->ClearAddresses();
$data['success'] = true;
$data['message'] = "Mail sent";
header("Content-Type: application/json; charset=utf-8", true);
// echo json_encode($data);
} else {
$data['success'] = false;
$data['message'] = "Mail Failed";
header("Content-Type: application/json; charset=utf-8", true);
// echo json_encode($data);
}
$data['success'] = true;
$data['message'] = "Mail sent";
header('Content-type: application/json');
header('Location: ../thank-you.html');
Back to Directory
File Manager