无法使PHPMailer工作

这个问题已经在这里有了答案:            >            PHP parse/syntax errors; and how to solve them?                                    17个
我正在努力安装PHPMailer并在我的应用程序中工作.

安装似乎很简单.
我的目录结构如下所示:

|-[controllers]
|---controller.php
|-[vendor]
|---[PHPMailer]
|------class.phpmailer.php
|------PHPMailerAutoload.php
|-index.php

的index.php

<?php
   ...
   require __DIR__ . '/vendor/PHPMailer/PHPMailerAutoload.php';
   ...
?>

Controller.php这样

<?php
    include('vendor/PHPMailer/class.phpmailer.php');
    $mail = new PHPMailer();
    ...
?>

这与示例所获得的一样简单,但是当我运行它时,出现以下错误:

Parse error: syntax error, unexpected end of file in
C:\wamp\www\commway\vendor\PHPMailer\class.phpmailer.php on line 2995

一切工作正常,我看不到如何解决这个问题.
我什至尝试将所有内容都移到index.php文件,但得到相同的结果.一旦我调用$mail = new PHPMailer();它引发错误.

解决方法:

我正在运行此代码:

//      PHPmailer

require 'PHPMailer-master/PHPMailerAutoload.php';

$mail = new PHPMailer;
$mail->CharSet = 'UTF-8';
$mail->isSMTP();                            // Set mailer to use SMTP
$mail->Host = SMTP;                         // Specify main and backup SMTP servers/*

$mail->From = EMAIL;
$mail->FromName = SENDER;
$mail->addAddress($Email, $FirstName);      // Add a recipient
$mail->WordWrap = 50;                       // Set word wrap to 50 characters
$mail->isHTML(true);                        // Set email format to HTML

$mail->Subject = $mailSubject;
$mail->Body    = $message;

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent to ' . $Email . "<br>";
} 

//      end of PHPmailer

结构:

PHPMailer-Master
-class.phpmailer.php
-class.pop3.php
-class.smtp.php
-PHPmailerAutoload.php
上一篇:PHP Mailer花费30多秒钟发送欢迎电子邮件


下一篇:使用PHPmailer发送多封电子邮件