<?php


use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '../vendor/autoload.php';


// passing true in constructor enables exceptions in PHPMailer
$mail = new PHPMailer(true);

$enquirys =array("none","none","Advertising Enquiry","Commercial Opportunity","Other enquiries");
$array = [
    "foo" => "bar",
    "bar" => "foo",
];
try {
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'josh.hodgetts@vidtiser.com.au';                 // SMTP username
$mail->Password = 'mznyehohdafiymrd';                           // SMTP password
$mail->SMTPSecure = 'tls';
$mail->Port = 587;                                    // TCP port to connect to

   // Sender and recipient settings
   $mail->setFrom($_POST["email"], $_POST["name"]);
   $mail->addAddress('sales@pixelar.com.au', 'Receiver Name');
   $mail->addReplyTo($_POST["email"], $_POST["name"]); // to set the reply to
   
   // Setting the email content
   $mail->IsHTML(true);
   $mail->Subject = "User Contact Information";
   $mail->Body =  '<table style=" background:#F4F4F4 ; text-align : center">
	
	<tr>
		<th colspan="2" style="padding:10px;">
			<b>Contact Details</b>
		</th>
	</tr>
	<tr>
		<td style="padding:10px;">
			<b>Company Name:</b>
		</td>
		<td style="padding:10px;">'.$_POST["company"].'</td>
	</tr>
	<tr>
		<td style="padding:10px;">
			<b>Name:</b>
		</td>
		<td style="padding:10px;">'.$_POST["name"].'</td>
	</tr>
	<tr>
		<td style="padding:10px;">
			<b>E-mail:</b>
		</td>
		<td style="padding:10px;">'.$_POST["email"].'</td>
	</tr>
	<tr>
		<td style="padding:10px;">
			<b>Contact:</b>
		</td>
		<td style="padding:10px;">'.$_POST["phone"].'</td>
	</tr>
	<tr>
		<td style="padding:10px;">
			<b>Type of enquiry:</b>
		</td>
		<td style="padding:10px;">'.$enquirys[$_POST["type"]].'</td>
	</tr>
	<tr>
		<td style="padding:10px;">
			<b>Message:</b>
		</td>
		<td style="padding:10px;">'.$_POST["message"].'</td>
	</tr>
	
	
	<tr>
		<th colspan="2" style="padding:10px;">
			<b>Thank you for contacting us.</b>
		</th>
	</tr>
	<tr>
		<td colspan="2" style="padding:10px;">
			You are very important to us, all information received will always remain confidential.
		</td>
		
	</tr>
</table>';
$mail->send();
echo "Email message sent.";
} catch (Exception $e) {
echo "Error in sending email. Mailer Error: {$mail->ErrorInfo}";
}

?>