I just downbloaded the PHPMailer zipped file, saved it to my host server and installed / extracted the PHPMailer files. When I added a require statement to use the PHPMailer.php file, I got the following error message:
Parse error: syntax error, unexpected '[' in D:\InetPub\vhosts\ ******.com\ *********.com\language\PHPMailer\src\PHPMailer.php on line 288
Doesn't this mean that there is an error in the PHPMailer.php file that was downloaded? If yes, is there a corrected file that I can use in its place? Here's the php code that I am trying to run:
<?php
ini_set('include_path','D:\inetpub\vhosts\******.com\*********.com\included_files;D:\inetpub\vhosts\******.com\*********.com\referenced_files;D:\inetpub\vhosts\******.com\*********.com\language;D:\inetpub\vhosts\******.com\*********.com\language\PHPMailer;D:\inetpub\vhosts\******.com\*********.com\language\PHPMailer\language;D:\inetpub\vhosts\******.com\*********.com\language\PHPMailer\src');
include("incPHP1.inc");
require 'Exception.php';
require 'PHPMailer.php';
require 'SMTP.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $mailHost; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $mailUser; // SMTP username
$mail->Password = $mailPassword; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('*******@rlchealth.com', 'Mailer');
$mail->addAddress('****@rlchealth.net', 'Joe User'); // Add a recipient
$mail->addAddress('*********@rlchealth.com'); // Name is optional
$mail->addReplyTo('********@rlchealth.com', 'Information');
$mail->addCC('************@*****.com');
$mail->addBCC('************r*****l.com');
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
?>
This issue is of your PHP version i guess u are using php 5.3 and phpMiller is for 5.6.
Please change ur php version and try again.