<?php 
include_once "../includes/connectConfig.php";

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

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

if($_POST){
	
	$comname = ucwords(test_input($_POST['inqname']));
	$commail = test_input($_POST['inqemail']);
	$comsubj = test_input($_POST['inqsubject']);
	$commessage = test_input($_POST['inqmessage']);
	
	
	$set_msgs = '<!DOCTYPE html>
<html>

<head>
    <title>Contact</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <style type="text/css">
        @media screen {
            @font-face {
                font-family: \'Lato\';
                font-style: normal;
                font-weight: 400;
                src: local(\'Lato Regular\'), local(\'Lato-Regular\'), url(https://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format(\'woff\');
            }

            @font-face {
                font-family: \'Lato\';
                font-style: normal;
                font-weight: 700;
                src: local(\'Lato Bold\'), local(\'Lato-Bold\'), url(https://fonts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff) format(\'woff\');
            }

            @font-face {
                font-family: \'Lato\';
                font-style: italic;
                font-weight: 400;
                src: local(\'Lato Italic\'), local(\'Lato-Italic\'), url(https://fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff) format(\'woff\');
            }

            @font-face {
                font-family: \'Lato\';
                font-style: italic;
                font-weight: 700;
                src: local(\'Lato Bold Italic\'), local(\'Lato-BoldItalic\'), url(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff) format(\'woff\');
            }
        }

       
        body,
        table,
        td,
        a {
            -webkit-text-size-adjust: 100%;
            -ms-text-size-adjust: 100%;
        }

        table,
        td {
            mso-table-lspace: 0pt;
            mso-table-rspace: 0pt;
        }

        img {
            -ms-interpolation-mode: bicubic;
        }
		
        img {
            border: 0;
            height: auto;
            line-height: 100%;
            outline: none;
            text-decoration: none;
        }

        table {
            border-collapse: collapse !important;
        }

        body {
            height: 100% !important;
            margin: 0 !important;
            padding: 0 !important;
            width: 100% !important;
        }

        a[x-apple-data-detectors] {
            color: inherit !important;
            text-decoration: none !important;
            font-size: inherit !important;
            font-family: inherit !important;
            font-weight: inherit !important;
            line-height: inherit !important;
        }
		
        @media screen and (max-width:600px) {
            h1 {
                font-size: 32px !important;
                line-height: 32px !important;
            }
        }
		
        div[style*="margin: 16px 0;"] {
            margin: 0 !important;
        }
        
    </style>
</head>

<body style="background-color: #f4f4f4; margin: 0 !important;padding: 0 !important;">
    
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
        
        <tr>
            <td align="center" style="padding: 0px 10px 0px 10px;">
                <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                    <tr>
                        <td bgcolor="#e92883"  align="center" valign="top" style="padding: 20px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: \'Lato\', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;">
                           <img src="https://www.shield.edu.gh/img/logo.png" width="200" height="120" alt="Shield International School Logo" style="display: block; border: 0px;" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td align="center" style="padding: 0px 10px 0px 10px;">
                <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                    
					
		<tr>
			<td  align="left">
				<div style="-webkit-box-shadow: 0 4px 6px 0 rgb(85 85 85 / 9%), 0 1px 20px 0 rgb(0 0 0 / 8%), 0px 1px 11px 0px rgb(0 0 0 / 6%);
		-moz-box-shadow: 0 4px 6px 0 rgba(85, 85, 85, 0.0901961), 0 1px 20px 0 rgba(0, 0, 0, 0.08), 0px 1px 11px 0px rgba(0, 0, 0, 0.06);
		box-shadow: 0 4px 6px 0 rgb(85 85 85 / 9%), 0 1px 20px 0 rgb(0 0 0 / 8%), 0px 1px 11px 0px rgb(0 0 0 / 6%);
		padding: 20px;	position: relative;	background-color: #fff;	border-radius: 6px;">
					<table style="width:100%">
		
						<thead>
						
							<tr>
								<th colspan="2" style="color: #1b55e2;	font-weight: 700;	font-size: 13px;	letter-spacing: 1px;	text-transform: uppercase;	vertical-align: bottom;
		                    	border-bottom: none;	border: 1px solid #ebedf2;	padding: 0.75rem;	text-align: center!important;	background-color: #f8f9fa!important;">Enquiry Message</th>
							</tr>
							
						</thead>
						
						<tbody>
						
					<tr>
						<td style="background: #0ea59a !important;color: #FFF !important;text-align:center;vertical-align: middle;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 700!important;">Name</td>
						
						<td style="text-align:left;vertical-align: middle;color: #515365;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 500!important;">'.$comname.'</td>
					</tr>
					
					<tr>
						<td style="background: #0ea59a !important;color: #FFF !important;text-align:center;vertical-align: middle;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 700!important;">Email</td>
						
						<td style="text-align:left;vertical-align: middle;color: #515365;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 500!important;">'.$commail.'</td>
					</tr>
					
					<tr>
						<td style="background: #0ea59a !important;color: #FFF !important;text-align:center;vertical-align: middle;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 700!important;">Subject</td>
						
						<td style="text-align:left;vertical-align: middle;color: #515365;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 500!important;">'.$comsubj.'</td>
					</tr>
					
					
					<tr>
						<td style="background: #0ea59a !important;color: #FFF !important;text-align:center;vertical-align: middle;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 700!important;">Message</td>
						
						<td style="text-align:justify;vertical-align: middle;color: #515365;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 500!important;">'.nl2br($commessage).'</td>
					</tr>
					
					<tr>
						<td style="background: #0ea59a !important;color: #FFF !important;text-align:center;vertical-align: middle;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 700!important;">Date</td>
						
						<td style="text-align:left;vertical-align: middle;color: #515365;font-size: 13px;letter-spacing: 1px;border: 1px solid #ebedf2;padding: 0.75rem;font-weight: 500!important;">'.date('D jS F,Y').'</td>
					</tr>
						
						</tbody>
					</table>
				</dv>
			</td>
		</tr>

		</table>
            </td>
        </tr>
    </table>
</body>

</html>';



$mail = new PHPMailer(true); 
try {
    //Server settings
    
	/*
	$mail->isSMTP();                                     
    $mail->Host = 'fenngreens.com';                      
    $mail->SMTPAuth = true;                             
    $mail->Username = 'info@fenngreens.com';     
    $mail->Password = '@Fenngreen24';             
    $mail->SMTPOptions = array(
        'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
        )
    );                         
    $mail->SMTPSecure = 'ssl';                           
    $mail->Port = 465;                                   

    $mail->setFrom($commail);
    $mail->addAddress("info@fenngreens.com");
    $mail->addReplyTo($commail);
    
    $mail->isHTML(true);                                  
    $mail->Subject = "Enquiry Message";
    $mail->Body    = $set_msgs;

    $mail->send();
    */
   //success
   $output["gerr"] = 'garrant';
   $output["prmt"] = '<div class="alert alert-arrow-left alert-icon-left mb-4 py-2 d-block alert-light-success " role="alert">
						<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-bell"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>
						<h5 class="text-dark text-center d-block mb-0 font-weight-bold">Success! Thanks For Reaching Us, Your Response is been Processed.</h5>
					</div>';

	echo json_encode($output);
	exit;
    
} catch (Exception $e) {
  
   //error
   //error code $mail->ErrorInfo;
   $output["gerr"] = 'warrant';
   $output["prmt"] = '<div class="alert alert-arrow-left alert-icon-left mb-4 py-2 d-block alert-light-danger " role="alert">
						<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-bell"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>
						<h5 class="text-dark text-center d-block mb-0 font-weight-bold">Failed! Request not sent, Try again.</h5>
					</div>';
   echo json_encode($output);
	exit;
}


	
}


?>