安裝過程正常
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(); //這行報錯
https://github.com/PHPMailer/PHPMailer#a-simple-example
use PHPMailer\PHPMailer\PHPMailer;
按照他們文檔是這樣引用吧 。不是use phpmailer\phpmailer\PHPMailer;
,你大小寫都不對。