I am troubleshooting a code I inherited, and code that includes PHPMailer stopped working earlier this week. Here is a stripped-down code version with echo statements inserted to see where it fails.
<?php
echo '<p>First Debug line<br></p>';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
echo '<p>after use<br></p>';
require 'vendor/autoload.php';
echo '<p>after vendor/autoload.php<br></p>';
$mail = new PHPMailer(true);
echo '<p>After PHPMailer<br></p>'; // this statement does not get executred
REV 1. Added following error trapping and I get the following now. What is puzzling to me that it was working a couple of days ago...
First Debug line
after use
after vendor/autoload.php
Fatal error: Uncaught Error: Class 'PHPMailer\PHPMailer\PHPMailer' not found in...
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
echo '<p>First Debug line<br></p>';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
echo '<p>after use<br></p>';
require 'vendor/autoload.php';
echo '<p>after vendor/autoload.php<br></p>';
$mail = new PHPMailer(true);
echo '<p>After PHPMailer<br></p>';