I am trying to use PHPMailer but I get a 500 internal server error, but the weird thing is that I do still get the mail in my inbox. This is the code I am using (stars for my password for security reasons)
<?php
require 'PHPMailerAutoload.php';
$name = htmlspecialchars($_POST['name']);
$subject = htmlspecialchars($_POST['subject']);
$txt = $_POST['content'];
$email = strtolower($_POST['email']);
$mail = new PHPMailer;
//$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 = 'wo***oom@gmail.com'; // SMTP username
$mail->Password = '***'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom($email, 'Mailer');
$mail->addAddress('wo***oom@gmail.com'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = 'Email van: <b>'. $name .'</b>.<br> Bericht:<br>'. $txt .'';
$mail->AltBody = 'Email van: '. $name .'. Bericht: '. $txt .'';
if(!$mail->send()) {
echo 'Bericht is niet verstuurd.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
header("contact.php");
}
header("contact.php");
?>
I get the mail with the right headers, content and sender in my inbox but the error stays