包含 class 时未找到 PHPMailer class

PHPMailer class not found when including the class

我已经从 github 下载安装了 PHPMailer master.zip

下面我用的时候

<?php

require "PHPMailer.php"; //include phpmailer class

// Instantiate Class
$mail = new PHPMailer();

// Set up SMTP
$mail->IsSMTP();                // Sets up a SMTP connection
$mail->SMTPAuth = true;         // Connection with the SMTP does require authorization
$mail->SMTPSecure = "ssl";      // Connect using a TLS connection
$mail->Host = "smtp.gmail.com";  //Gmail SMTP server address
$mail->Port = 465;  //Gmail SMTP port
$mail->Encoding = '7bit';

我得到以下

ubuntu@ip-172-31-35-156:/opt/PHPMailer-master/src$ php test.php
PHP Fatal error:  Uncaught Error: Class 'PHPMailer' not found in /opt/PHPMailer-master/src/test.php:6
Stack trace:
#0 {main}
  thrown in /opt/PHPMailer-master/src/test.php on line 6
ubuntu@ip-172-31-35-156:/opt/PHPMailer-master/src$ 

我做错了什么?

附加文件夹结构

PHPMailer 默认在 PHPMailer\PHPMailer 命名空间中,您可以使用 use 关键字将其引入全局命名空间。例如在他们的 simple_contact_form 示例中:

<?php
//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;