使用composer安装PHPMailer后,总是报错Error: Class 'phpmailer\phpmailer\PHPMailer' not found

0

安装过程正常


composer require phpmailer/phpmailer
Using version ^6.1 for phpmailer/phpmailer
./composer.json has been updated
Running composer update phpmailer/phpmailer
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking phpmailer/phpmailer (v6.1.7)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Downloading phpmailer/phpmailer (v6.1.7)
- Installing phpmailer/phpmailer (v6.1.7): Extracting archive
3 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
15 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

代码中:
//引入
use phpmailer\phpmailer\PHPMailer;
//使用
$mail = new PHPMailer(); //这行报错

已邀请:

xiuwang

赞同来自:

https://github.com/PHPMailer/PHPMailer#a-simple-example


use PHPMailer\PHPMailer\PHPMailer;

按照他们文档是这样引用吧 。不是use phpmailer\phpmailer\PHPMailer;,你大小写都不对。

要回复问题请先登录注册