<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

// Load Composer's autoloader
require './vendor/autoload.php';

// Instantiation and passing `true` enables exceptions
$email=$_POST['email'];
$Name=$_POST['name'];
$Contact=$_POST['phone'];
$Enquiry=$_POST['enquiry'];
$Message=$_POST['message'];
$mail = new PHPMailer(true);

try {
    //Server settings
   
    $mail->IsSMTP(true);
    $mail->Host = 'smtp.zoho.com'; // not ssl://smtp.gmail.com
    $mail->SMTPAuth= true;
    $mail->Username='enquiry@zorbaconsulting.in';
    $mail->Password='Zorba@123';
    $mail->Port = 465; // not 587 for ssl 
    $mail->SMTPDebug = 0; 
    $mail->SMTPSecure = 'ssl';
    $mail->SetFrom('enquiry@zorbaconsulting.in', 'zorbaconsulting');
    $mail->AddAddress('enquiry@zorbaconsulting.in', 'zorbaconsulting');
    $mail->Subject = 'Contact sent from the zorbaconsulting.';
    $mail->Subject = "Contact sent from the zorbaconsulting.";
    // $mail->Body    = "This is the HTML message body <b>in bold!</b>";
    $mail->Body = " <style>
    table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
    
    }
    th, td {
    padding: 5px;
    text-align: left;    
    }
    </style>
    <table style='width:50%'>   
    <tr><th>Name</th><td><b>$Name</b></td></tr>
    <tr><th>Email-Id</th><td><b>$email</b></td></tr>
    <tr><th>Contact</th><td><b>$Contact</b></td></tr>
    <tr><th>Enquiry</th><td><b>$Enquiry</b></td></tr>
    <tr><th>Message</th><td><b>$Message</b></td></tr>
    </table> 
      ";
    $mail->AltBody = "This is the body in plain text for non-HTML mail    clients";


    if($mail->Send()) {
        echo "<script type='text/javascript'>
          alert('Thank you for your Enquiry');
          location='contact-us';
            </script>";
           // header('Location: Contact.html');     
    }
    else{
        echo "<script type='text/javascript'>
              alert('Try Again Later');
              location='contact-us.html';
                </script>";
    }   
} 
catch (Exception $e) {
    // echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}