<?php
ob_start();

$name = $_POST['name'];
$email =  $_POST['email'];
$contact =  $_POST['contact'];
$message = $_POST['message'];

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';

if(isset($email)){

    $mail = new PHPMailer(true);
    
    $mail->isSMTP();
    $mail->Host = 'smtp.gmail.com';
    $mail->SMTPAuth = true;
  $mail->Username = 'leads.sandblaze@gmail.com';
  $mail->Password = 'gbvyzbspyimccvrx';
    //$mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    
    $mail->setFrom('leads.sandblaze@gmail.com');
    
    //$mail->addAddress($email);
    //$mail->addAddress('sivakrishna.sandblaze@gmail.com');
      $mail->addAddress('rsrinivas.sandblaze@gmail.com');
      // $mail->addAddress('admission.isebanglore@gmail.com');
      $mail->AddBCC('srinivas.sandblazedigitals@gmail.com');    
    
    $mail->isHTML(true);
    
    $mail->Subject = "Contact";
    $mail->Body    = 
        "<html>
            <head>
            <title>Srujana High School</title>
            </head>
            <body style='border:15px solid #cccccc36;;padding:20px;'>
           
             <p><img src='' style='width: 120px;' /></p>
             <p style='border-top:1px solid #ccc;' ></p>

              <p> Name : $name</P>
              <p> Email : $email</P>
              <p> Contact No : $contact</P>             
              <p> Message : $message</p>

            </body>
        </html>
        ";
    
     $mail->send();



// $sql="INSERT INTO appointments (name,mobile,email,date,service,problem) 
// VALUES 
// ( '{$name}','{$mobile}','{$email}','{$datetime}','{$ser}','{$msg}')";


header("Location: thankyou");
} else {
    header("Location: error.html");
}

?>
