<?php

$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$user_message = $_POST["message"];

require 'PHPMailer/class.phpmailer.php';
$subject= "Dear Admin - New Message.";
$mail = new PHPMailer(true); 
$mail->IsSMTP();                           
$mail->SMTPAuth   = true;                 
$mail->Port       = 465;                    
$mail->Host       = "shipeasedelivery.online"; 
$mail->Username   = "shipeasedelivery.online";   
$mail->Password   = "Shipease@4100";
$mail->SMTPSecure = "SSL";
$mail->AddReplyTo($email,$name);
$mail->AddCustomHeader("X-MSMail-Priority: High");
$mail->IsSendmail(); 
$mail->From       = "support@shipeasedelivery.online";
$mail->FromName   = "ShipEaseDelivery";
$mail->AddAddress("support@shipeasedelivery.online");
$mail->Subject  = $subject;
$mail->WordWrap   = 80;
$message = '
    <div>
        <h2>Dear Admin</h2>
        <b>'.$name.'</b> visited your site and dropped this message:<br>
        '.$user_message.'<br>
        <div>
            Sent from : <b>'.$email.'</b><br>
            Phone number : <b>'.$phone.'</b>
        </div>
    </div>
';
$mail->MsgHTML($message);
$mail->IsHTML(true); 
if($mail->Send()) {
  echo "<script>
  			alert('Message Sent');
		    window.location.href = 'contact.html';
		</script>";
} else {
    echo "Failed to send";
}




/*



include 'db.php';
include 'config.php';
$msg = '';
	if (isset($_POST['submit'])) {
		$name = trim($_POST['name']);
		$email = trim($_POST['email']);
		$phone = trim($_POST['phone']);
		$message = trim($_POST['message']);

		if (!empty($name) && !empty($email) && !empty($phone) && !empty($message)) {
		    $subj = "Contact Form";
			 $body = "<table>
		    	<tr> Name - </tr>
		    	<tr> ".$name." </tr><br><br>
		    	<tr> Email - </tr>
		    	<tr> ".$email." </tr><br><br>
		    	<tr> Phone Number - </tr>
		    	<tr> ".$phone." </tr><br><br>
		    	<tr> Message - </tr>
		    	<tr> ".$message." </tr><br><br>
		     </table>";
		    $send = sendMail($email_name, $subj, $body);
		    if ($send) {
		    	
		    	echo "<script>alert('Message Sent');
		    	window.location.href = 'contact.html' 
		    	</script>";
		    	
		    }
		}
		
	}else{
	    echo "<script>
		    	window.location.href = 'contact.html' 
		    	</script>";
	}




*/









?>