找不到PHPMailer类

找不到PHPMailer类,php,codeigniter,phpmailer,Php,Codeigniter,Phpmailer,我让PHPMailer在本地环境中使用我的代码,但是当我将其移动到服务器时,我得到以下错误 Class 'PHPMailer\PHPMailer\PHPMailer' not found 下面是我使用的代码位: use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; class Email extends EV_DB { function __construct() { parent::__con

我让PHPMailer在本地环境中使用我的代码,但是当我将其移动到服务器时,我得到以下错误

Class 'PHPMailer\PHPMailer\PHPMailer' not found
下面是我使用的代码位:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

class Email extends EV_DB {
  function __construct() {
    parent::__construct();
    $this->email_common  = [
      'baseurl' => $_SERVER['HTTP_HOST']
    ];
    $this->stache = new Mustache_Engine(array(
        'loader' => new Mustache_Loader_FilesystemLoader( __DIR__ .'/../../mustache'),
    'partials_loader' => new Mustache_Loader_FilesystemLoader( __DIR__  .'/../../mustache/partial')
));
    $mail = new PHPMailer(true);
...
我用composer安装了PHPMailer,并将codeigniter设置为在配置文件中自动加载,这就是为什么不需要autoload.php。我确信这是正确的,因为Mustach加载很好,如果我尝试手动包含autload文件,它会给我错误:

Cannot declare class ComposerAutoloaderInitb315d7432979fc7d6789bb454c858180, because the name is already in use.
本地环境和实时环境的区别在于,我的应用程序文件夹与index.php所在的位置是分开的。因此,在index.php中,我设置了:

$application_folder = 'C:\inetpub\my_application\application';
当索引文件位于

C:\inetpub\wwwroot\MyApplication\index.php

此位置更改是否更改了名称空间的设置?我真的不知道如何排除这一点。

最后通过composer重新安装PHPMailer就成功了。我猜安装过程中出了问题。哎哟。

请展示如何在composer中定义phpmailer?@Alex“phpmailer/phpmailer”:“~6.0”只是一种预感,可能名称空间是错误的。您是否尝试过:使用PHPMailer\PHPMailer;使用PHPMailer\Exception@billrichards也试过,同样的问题。我曾经写过一本指南——也许有帮助——但我没有看到任何错误——你确定那些文件在你的服务器上吗?