How can the error "Class 'PHPMailer' not found" be resolved when using PHPMailer in a PHP project?

The error "Class 'PHPMailer' not found" occurs when the PHP script cannot find the PHPMailer class definition. To resolve this issue, you need to include the PHPMailer autoloader or require the PHPMailer class file in your PHP project before using it.

// Include the PHPMailer autoloader
require 'vendor/autoload.php';

// Create a new PHPMailer instance
$mail = new PHPMailer\PHPMailer\PHPMailer();