<?php
session_start();

if(!isset($_POST['submit'])){
	exit('Fail!');
}
$email = htmlspecialchars($_POST['email']);
$message = preg_replace("/\r\n/", '<br>',htmlspecialchars($_POST["message"]));
$created = date("Y-m-d H:i:s"); 
$name = htmlspecialchars($_POST['name']);
$phone = htmlspecialchars($_POST['phone']);
include('../../conf/conn.php');

$query = "insert into messages(name,phone,email,message,time) values ('$name', '$phone', '$email', '$message', '$created')";
$result=mysqli_query($conn,$query);

	require_once('../../phpmailer/class.phpmailer.php');
		$mail = new PHPMailer(); // create a new object
		$mail->IsSMTP(); // enable SMTP
		$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
		//$mail->SMTPAuth = true; // authentication enabled
		//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
		//$mail->Host = "localhost";
		//$mail->Host = "smtp.gmail.com";
		$mail->Host = "localhost";
		//$mail->Port = 465; // or 587		
		
		
		$mail->AddBCC("daniel@at-creative.com");
$mail->AddBCC("info@sayvour.com.hk");
$mail->AddBCC("catherine@sayvour.com.hk");
		$mail->AddBCC("sayvourhongkong@gmail.com");
		$mail->IsHTML(true);
		//$mail->Username = "kk@at-creative.com";
		//$mail->Password = "artech0088";
		$mail->SetFrom("info@sayvour.com.hk","Sayvour");
		$mail->Subject = "Thank you for your enquiry";
		$mail->Body = "                 <!-- top bar -->

                <div id=':lt' class='ii gt adP adO'>
                    <div id=':ls' class='a3s aXjCH m156312919a8bb8e9'><u></u>
                        <div style='margin:0;padding:0'>
													<div style='min-width:320px;background-color:#c2e3e3' lang='x-wrapper'>
														<div style='Margin:0 auto;max-width:560px;min-width:280px;'>
                                    <div style='border-collapse:collapse;display:table;width:100%'>
                                        <div style='Float:left;font-size:12px;line-height:19px;max-width:280px;min-width:140px;padding:10px 0 5px 0;color:#9dc4c4;font-family:Cabin,Avenir,sans-serif'></div>
                                        <div style='Float:left;font-size:12px;line-height:19px;max-width:280px;min-width:139px;padding:10px 0 5px 0;text-align:right;color:#9dc4c4;font-family:Cabin,Avenir,sans-serif'></div>
                                    </div>
                                </div>
                                <div style='Margin:0 auto;max-width:600px;min-width:320px;'>
                                    <div style='font-size:26px;line-height:32px;Margin-top:6px;Margin-bottom:20px;color:#ffffff;font-family:&quot;PT Serif&quot;,Georgia,serif;Margin-left:20px;Margin-right:20px' align='center'>
                                        <div style='font-size:0px!important;line-height:0!important' align='center'><img style='min-height:auto;width:100%;border:0;max-width:217px' src='https://ci4.googleusercontent.com/proxy/vUMxJkR_Kw9qDMrAUmEEtS4_hy8v4TztsG8zNDbLJxG0zizdPUmHdqEAaVAuRWqrT0fA9zde7TizwG9QGRXUNgPmnlhNJWJ_gzMCbqpsW3bSMaNbueUnoTh1=s0-d-e1-ft#http://i1.cmail2.com/ei/d/F9/F24/F62/203623/csfinal/sayvour-logo.png' alt='' width='217' class='CToWUd'></div>
                                    </div>
                                </div>
                
                <!-- end top bar -->
                
                <!-- Dear -->
										<div style='background-color:#FFFFFF'>
					<div style='Margin:0 auto;max-width:600px;min-width:320px;word-wrap:break-word;word-break:break-word'>
						<div style='border-collapse:collapse;display:table;width:100%'>
							<div style='max-width:600px;min-width:320px;text-align:left;FONT-SIZE:9pt;FONT-FAMILY:&quot;Helvetica&quot;,sans-serif;COLOR:#333333'>
								<div style='Margin-left:20px;Margin-right:20px'>
									<div style='line-height:40px;font-size:1px'>&nbsp;</div>
								</div>
								<div style='Margin-left:20px;Margin-right:20px'>
									<h1 style='Margin-top:0;Margin-bottom:20px;font-style:normal;font-weight:normal;color:#499f9e;font-size:24px;line-height:32px;font-family:&quot;PT Serif&quot;,Georgia,serif;text-align:center' lang='x-size-28'>Thank you for your enquiry from Sayvour</h1>
								</div>
								<div style='Margin-left:20px;Margin-right:20px'>
									<p style='Margin-top:0;Margin-bottom:0;text-transform: capitalize'>Dear&nbsp;".$name.",</p><p style='Margin-top:20px;Margin-bottom:20px'>Thank you for your enquiry on ". date('d F Y').".<br><br>

Your enquiry is: <br>".$message."<br><br>

We will get back to you as soon as possilble. We hope that you and your loved ones will
savour every mouthful of our delicacies and every moment of receiving the personalised
gifts made by us. We look forward to serving you soon.									
									
									
									
									</p>
								</div>
								<div style='Margin-left:20px;Margin-right:20px'>
									<div style='line-height:20px;font-size:1px'>&nbsp;</div>
				</div>
                
                <!-- End Dear -->


                <div style='Margin-left:20px;Margin-right:20px'>
                    <div style='line-height:20px;font-size:1px'>&nbsp;</div>
                </div>
                      
				<div style='Margin-left:20px;Margin-right:25px'>
									<p style='Margin-top:0;Margin-bottom:20px;font-size:14px;line-height:21px;text-align:left' lang='x-size-14'>
									Best regards,</p>
								</div>
								<div style='font-size:12px;font-style:normal;font-weight:normal' align='left'>
									<a href='http://www.sayvour.com.hk'><img style='border:0;display:block;min-height:auto;width:100%;max-width:150px; padding-left:20px' alt='' width='249' src='https://ci4.googleusercontent.com/proxy/WhjL_vvSpLarh-zQTnIIub3yktIgmMYyzgWhl_XTAMbJQ9LIpv2A32hCNW_U3MQg3wHDHewv_AnV0ysjc7_dtTBbxdltT6OvngagFLBQ44sF8Vmw8QWrq9G8jgY=s0-d-e1-ft#http://i1.cmail2.com/ei/d/F9/F24/F62/203624/csfinal/Sayvour-logo-b.png' class='CToWUd'></a>
								</div>
								<div style='Margin-left:20px;Margin-right:20px;Margin-top:20px'>
									<p style='Margin-top:0;Margin-bottom:20px'>Sayvour | Say Your Flavour</p>
								</div>
								<div style='Margin-left:20px;Margin-right:20px'>
									<div style='line-height:5px;font-size:1px'>&nbsp;</div>
								</div>
								<div style='Margin-left:20px;Margin-right:20px'>
									<div style='line-height:5px;font-size:1px'>&nbsp;</div>
								</div>
								<div style='Margin-left:20px;Margin-right:20px'>
									<div style='line-height:5px;font-size:1px'>&nbsp;</div>
								</div>
							</div>
						</div>
					</div>
				</div>				
                
               	<!-- End Best regards -->                

                
                <!-- footer  -->
                
				<div style='Margin:0 auto;max-width:600px;min-width:320px;word-wrap:break-word;word-break:break-word'>
					<div style='border-collapse:collapse;display:table;width:100%'>
						<div style='text-align:left;font-size:12px;line-height:19px;color:#7A7A7A;font-family:Cabin,Avenir,sans-serif;Float:left;max-width:400px;min-width:320px;'>
							<div style='Margin-left:20px;Margin-right:20px;Margin-top:10px;Margin-bottom:10px'>
								<table style='border-collapse:collapse;table-layout:fixed'>
									<tbody>
										<tr>
											<td style='padding:0;width:26px'><a style='text-decoration:underline;color:#9dc4c4' href='http://kk.cmail2.com/t/d-i-ijlhttd-l-r/' target='_blank'><img style='border:0' src='https://ci4.googleusercontent.com/proxy/cdaOVwx01pydUCeWanZ5I0WsxDjvph7JzEiKY3zimkrOp-LjXcGnE1GadRLWYfIKzlmiYSOtzr-WjjHJdYebPiyRLHmWcDY2Zz_HAol546DebSYvB0BcePndD26qkP8w-AE=s0-d-e1-ft#http://i8.cmail2.com/static/eb/master/13-the-blueprint-3/images/facebook.png' width='26' height='26' class='CToWUd'></a></td>
											<td style='padding:0 0 0 3px;width:26px'><a style='text-decoration:underline;color:#9dc4c4' href='http://kk.cmail2.com/t/d-i-ijlhttd-l-y/' target='_blank'><img style='border:0' src='https://ci5.googleusercontent.com/proxy/H7Yt85uks7gPb4DmaC8HgjAqYMQhhSna9kYBtoUZr5D3lFKE-IJtZdN1MqyIopBh8YJYDX-igm7ScYklACfkd0Y1wvJ0BbBd3m1bcejcougYGa1dWg76ozQ-vG28HEqFDCbI=s0-d-e1-ft#http://i1.cmail2.com/static/eb/master/13-the-blueprint-3/images/instagram.png' width='26' height='26' class='CToWUd'></a></td>
										</tr>
									</tbody>
								</table>
								<div style='Margin-top:20px'>
									<div>Patisserie Sayvour Limited</div>
								</div>
								<div style='Margin-top:18px'>
									<div>Sayvour is an artisan confectionery specialising in handmade chocolates and pastries by using high quality ingredients from around the world.</div>
								</div>
							</div>
						</div>
						<div style='text-align:left;font-size:12px;line-height:19px;color:#9dc4c4;font-family:Cabin,Avenir,sans-serif;Float:left;max-width:320px;min-width:200px;'>
							<div style='Margin-left:20px;Margin-right:20px;Margin-top:10px;Margin-bottom:10px'></div>
						</div>
					</div>
				</div>
				<div style='Margin:0 auto;max-width:600px;min-width:320px;word-wrap:break-word;word-break:break-word'>
					<div style='border-collapse:collapse;display:table;width:100%'>
						<div style='text-align:left;font-size:12px;line-height:19px;color:#9dc4c4;font-family:Cabin,Avenir,sans-serif;max-width:600px;min-width:320px;'>
						</div>
					</div>
				</div>
				<div style='line-height:40px;font-size:40px'>&nbsp;</div>
			</div>
			<img style='overflow:hidden;display:block!important;min-height:1px!important;width:1px!important;border:0!important;margin:0!important;padding:0!important' src='https://ci4.googleusercontent.com/proxy/-HQ08vlGM2ltqJyXUtWXZlorkMV10CQ0pH8IJ2TQo0JNoLOLepN2GqRqjNvhCsxelytv0dohcw2kweEKYfPeyqw=s0-d-e1-ft#https://kk.cmail2.com/t/d-o-ijlhttd-l/o.gif' width='1' height='1' border='0' alt='' class='CToWUd'>
			<div class='yj6qo'></div>
			<div class='adL'></div>
		</div>
		<div class='adL'></div>
	</div>
</div>

                <!--End  footer  -->
	


		";
		
		$mail->AddAddress($email);
		$mail->Send();
		echo "<script>";  
		echo 'window.history.go(-1);alert("Thank you for your enquiry. We will get back to you as soon as possible.");';
		echo '</script>';
?>