<?php
if (isset($_POST['submit']) && $_POST['submit'] == "Send Message") {
$secret = trim($_POST['ctrl']);
if ($secret === md5($_CONFIG['secret'])) {
//get values
$name = $_POST['name'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
$body = "Details of the message:<br><br>";
$body .= "Subject of the message: <b>".$subject."</b><br>";
$body .= "Name: <b>".$name."</b><br>";
$body .= "Email: <b>".$email."</b><br>";
$body .= "Message: <b>".$message."</b><br><br><br>";
$body .= "Other information: <br><br>";
$body .= "IP address: <b>".$_SERVER['REMOTE_ADDR']."</b><br>";
try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled
$mail->From = $email;
$mail->FromName = $name;
$mail->AddAddress($utils->getSettingValue('email'));
$mail->Subject = "email from the site";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
//$mail->WordWrap = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();
?>
<script type="text/javascript">
alert('The email has been sent successfully');
</script>
<?php
} catch (phpmailerException $e) {
?>
<script type="text/javascript">
alert('Problems with sending emails. Email not sent.<br><br>The error is: <br><br>' + <?php echo $e->errorMessage() ?>);
</script>
<?php
}
}
}
?>