<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

  
</head>

<body>
<?php

ob_start();

if(isset($_POST['submit']))
{
    
      /* Verify Email */
    include_once 'class.verifyEmail.php';
	$email = $_POST['email'];
    $vmail = new verifyEmail();
	$vmail->setStreamTimeoutWait(20);
	$vmail->setEmailFrom('viska@viska.is');
	$name=$_POST['name'];
	if (!$vmail->check($email) || !preg_match ("/^[a-zA-Z\s]+$/",$name)) {
?>
    <script>
           alert('This is not valid email id');
           history.go(-1);
    </script>
<?php

	}else{

    
require("class.phpmailer.php");

$mail = new PHPMailer();

//Your SMTP servers details

// Settings
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';

//Your SMTP servers details
$mail->Host       = "mail.aviatorsinfotech.in"; // SMTP server example
$mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Port       = 587;                    // set the SMTP port for the GMAIL server
$mail->Username = "mailenquiry@aviatorsinfotech.in";  // SMTP username
$mail->Password = "b@MN!C.K5Gr{"; // SMTP password

//It should be same as that of the SMTP user

$redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form
$mail->From =  $mail->Username;// $mail->Username;	//Default From email same as smtp user


$mail->FromName = $_POST['name'];

$mail->AddAddress("hashamali7@gmail.com");
    

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "Message from Website";
$message = "Name : ".$_POST['name'].
"\r\n <br>Email : ".$_POST['email'].
"\r\n <br>Subject : ".$_POST['subject'].
"\r\n <br>Message : ".$_POST['message'];
 

$mail->Body    = $message;

if(!$mail->Send())
{?>
  <script language="javascript" type="text/javascript">
	alert('Message failed.');
	window.location = 'contact-us.php';
  </script>
<?php
}

?>
<script language="javascript" type="text/javascript">
		alert('Message has been sent');
		window.location = 'contact-us.php'	
	</script>

  <?php
}

}
?>


</body>
</html>