<?php
if (isset($_POST['myName']) && empty($_POST['honeypot'])) {
$myName = $_POST['myName'];
$myEmail = $_POST['myEmail'];
$myQuestion = $_POST['myQuestion'];
date_default_timezone_set('Etc/UTC');
require '../PHPMailer/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP - requires a local mail server
//Faster and safer than using mail()
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'mail.myname.website.com';
$mail->Port = 587;
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = 'phpmailer@myname.website.com';
$mail->Password = 'AGoodPassword';
//Use a fixed address in your own domain as the from address
//**DO NOT** use the submitter's address here as it will be forgery
//and will cause your messages to fail SPF checks
$mail->setFrom('phpmailer@myname.website.com', 'My Name');
//Send the message to yourself, or whoever should receive contact for submissions
$mail->addAddress('firstname.lastname@email.edu', 'My Name');
//Put the submitter's address in a reply-to header
//This will fail if the address provided is invalid,
//in which case we should ignore the whole request
$mail->addReplyTo($myEmail, $myName);
$mail->Subject = 'PHT || Questions or Comments';
//Keep it simple - don't use HTML
$mail->isHTML(true);
//Build a simple message body
$mail->Body = <<<EOT
Email: $myEmail<br>
Name: $myName<br>
Message: $myQuestion
EOT;
//Send the message, check for errors
if (!$mail->send()) {
//The reason for failing to send will be in $mail->ErrorInfo
//but you shouldn't display errors to users - process the error, log it on your server.
echo "Mailer error" . $mail->ErrorInfo;
} else {
include 'sent.html.php';
}
} else {
include 'contact.html.php';
}
?>
I've changed the emails and password but the rest of the code is exactly the same.
For some backstory, I've been trying to figure out the problem with this code off and on for the last week. The short of it is it runs fine on Localhost, which is using Windows, but on my Webserver I'm immediately met with an HTTP Error 500. I checked the error logs and the only thing popping up is (Don't know if it was necessary but I edited some of the file names for this post):
PHP Parse error: syntax error, unexpected end of file in /home2/myname/public_html/'filepath'/'filepath'/'filepath/index.php on line 67
I ran my code through a PHP code checker here: https://phpcodechecker.com/
It gave me the same error:
PHP Syntax Check: Parse error: syntax error, unexpected end of file in your code on line 67
?>
I can't figure out why ?> would be an unexpected end of file. I thought maybe there was a syntax error earlier in the code, but after combing it several times everything seems to check out to my knowledge. Furthermore, I can't figure out why this code could run on Localhost but not my server. I've found a number posts on Stack Overflow where people are having the same problem but none of them have been helpful to my situation. Any ideas?
EDIT:
User 'ceejayoz' got it right. I fixed the indentation on the EOT; line and everything was fixed.