-3

After struggling with PHPmailer on my website I have yet to reach a solution. First, I was receiving fatal errors from my require() function but changed the path to relative and it worked. Next up, syntax error on line 7. I am not entirely sure why I am receiving an error, can anybody help?

<?php
$email = $_REQUEST['email'] ;

$message = $_REQUEST['message'] ;
require "PHPMailer/PHPMailerAutoload.php"

$mail = new PHPMailer();

$mail->IsSMTP();

$mail->Host = "localhost";

$mail->SMTPAuth = true;

$mail->Username = "(myemail)";  // SMTP username

$mail->Password = "(mypassword)"; // SMTP password

$mail->SMTPSecure = "tls";

$mail->Port = 587;

$mail->From = "(myemail)";

$mail->addAddress('anotheroneofmyemails'); 

// set word wrap to 50 characters
$mail->WordWrap = 50;

// set email format to HTML
$mail->IsHTML(true);

$mail->Subject = 'Customer Inquiry Information:';

$mail->Body = $message;

$mail->AltBody = $message;

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
?>
melpomene
  • 84,125
  • 8
  • 85
  • 148
JLTheCapo
  • 1
  • 1
  • 2

1 Answers1

5

You forgot the ; at the end of the require line.

melpomene
  • 84,125
  • 8
  • 85
  • 148
  • Thanks for your input. Now I am back to my original error: Fatal error: require() [function.require]: Failed opening required 'PHPMailer/PHPMailerAutoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a3785759/public_html/PHPMailer/test1.php on line 4 – JLTheCapo Jul 17 '16 at 00:04
  • @JLTheCapo Where did you put the `PHPMailerAutoload.php` file? – melpomene Jul 17 '16 at 00:05
  • I put the PHPMailerAutoload.php file in the PHPMailer directory, which is in the public_html directory. – JLTheCapo Jul 17 '16 at 00:10
  • @JLTheCapo Then you need to move the `test1.php` file one directory up (in `public_html`), or change it to `require "PHPMailerAutoload.php";`, or use an absolute path. – melpomene Jul 17 '16 at 00:12
  • I moved the test1.php file one directory up; no luck with that. From here, my new code (with absolute path) is: require PATH. '/public_html/PHPMailer/PHPMailerAutoload.php'; No luck. Any other suggestions? – JLTheCapo Jul 17 '16 at 00:23
  • Scratch that!!!! your first suggestion worked. I moved the test1.php file back into the PHPMailer directory, and went with the require "PHPMailerAutoload.php" and it seems to be working! Message didnt send because message body is empty, but THANK YOU! EDIT: SMTP connect failed, do you think it is obviously because 000webhost doesn't support SMTP? – JLTheCapo Jul 17 '16 at 00:26