新安装后使用PHPMailer时出错
我刚刚下载了PHPMailer压缩文件,将其保存到主机服务器,并安装/解压缩了PHPMailer文件。当我添加require语句以使用PHPMailer.php文件时,我收到以下错误消息: 分析错误:语法错误,第288行的D:\InetPub\vhosts\************.com\*********.com\language\PHPMailer\src\PHPMailer.php中出现意外“[” 这是否意味着下载的PHPMailer.php文件中存在错误?如果是,是否有一个更正的文件可以替代它?以下是我尝试运行的php代码:新安装后使用PHPMailer时出错,php,email,syntax-error,phpmailer,Php,Email,Syntax Error,Phpmailer,我刚刚下载了PHPMailer压缩文件,将其保存到主机服务器,并安装/解压缩了PHPMailer文件。当我添加require语句以使用PHPMailer.php文件时,我收到以下错误消息: 分析错误:语法错误,第288行的D:\InetPub\vhosts\************.com\*********.com\language\PHPMailer\src\PHPMailer.php中出现意外“[” 这是否意味着下载的PHPMailer.php文件中存在错误?如果是,是否有一个更正的文件可
<?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;
}
?>
本期是您的PHP版本,我想您使用的是PHP5.3,而phpMiller是5.6版本
请更改您的php版本并重试。您的php版本是什么?第288行上有什么?您的第一个问题的答案是php版本5.3.28。至于第288行上出现的内容,这是从GitHub下载的第三方软件。我不相信我可以合法地在这里重印该代码。我必须更改托管服务以获得我需要一个php版本,而不必为升级付出任何代价,但一旦升级,它立即开始工作。