<?php

//require './PHPMailerAutoload.php';
require "./PHPMailer_5.2.0/class.phpmailer.php";

$name = $_POST['username'];
$emailid = $_POST['emailid'];
$mobileno = $_POST['mobileno'];
$city = $_POST['city'];
$place = $_POST['place'];
$package = $_POST['package'];
$doctor = $_POST['doctor'];
$date = $_POST['date'];


if ($name == "") {
    echo 'Name is empty';
    exit();
}
if ($emailid == "") {
    echo 'Email is empty';
    exit();
}
if ($package == "") {
    echo 'Select Package';
    exit();
}

if ($date == "") {
    echo 'Date is empty';
    exit();
}

$output = '<!DOCTYPE html>
                                    <html>
                                    <head>
                                        <title>Request For Appointment</title>
                                        <meta charset="UTF-8">
                                        <meta name="viewport" content="width=device-width, initial-scale=1.0">
                                    </head>
                                    <body>  
                                    <p>Name : ' . $name . '</p>
                                    <p>Email : ' . $emailid . '</p>
                                    <p>Phone No : ' . $mobileno . '</p>
                                    <p>City : ' . $city . '</p>                                       
                                    <p>Place : ' . $place . '</p>                                       
                                    <p>Package : ' . $package . '</p>
                                        <p>Doctor : ' . $doctor . '</p>
                                    <p>Date : ' . $date . '</p>
                                    </body>
                                </html>';

/*$toaddress = "suddu.gp@gmail.com";
$mail = new PHPMailer();
$mail->isSendmail();
$mail->Subject = "Tathagat | Request For Appointment";
$mail->setFrom('info@tathagathearthospital.com', 'Tathagat');
$mail->addAddress($toaddress);
$mail->AddCC('lenus@bangaloreadsolutions.com');
$mail->IsHTML(true);
$mail->Body = preg_replace('/\[\]/', '', $output);*/

                $toaddress = "frontoffice@tathagathearthospital.com";    
                $mail = new PHPMailer();
    		    $mail ->IsSmtp();
                $mail->SMTPDebug = 0;
                $mail ->SMTPAuth = true;
    		    //$mail ->SMTPSecure = 'tls';
                $mail->Host = "mail.tathagathearthospital.com";
                $mail->Port = 587;   //587, 25;
    		    $mail ->IsHTML(true);
                $mail->Username = "info@tathagathearthospital.com";
                $mail->Password = "X+%7=mKrvwAs";
                $mail->SetFrom('info@tathagathearthospital.com	', 'Tathagat');
    		   
    		    $mail ->Subject = 'Tathagat | Request For Appointment';
    		    $mail ->Body = preg_replace('/\[\]/', '', $output);
    		    $mail ->AddAddress($toaddress);
    		    $mail->AddCC('mahanteshrc@tathagathearthospital.com');
    		    
if ($mail->send()) {
    echo 'ok';
    exit(0);
} else {
    echo 'Sorry.. Please try again later...';
    exit(0);
}
