Encountered PHPMailer undefined type error (tried using Composer also didn't work)
P粉921165181
P粉921165181 2023-11-12 17:35:06
0
1
728

I don't know why I'm getting this "PHPMailer undefined type" error. First, I tried downloading the zip directly and copying the code from github, the same problem appeared, then I downloaded composer which I didn't want to download, but after downloading it still showed the same error.

Can I have any thoughts on this? (Screenshot below)

Composer img error

Same error occurs without composer img

Catalog Pictures

This is the code

session_start();

// Import PHPMailer classes into the global namespace 
use PHPMailerPHPMailerPHPMailer; 
use PHPMailerPHPMailerException; 
 
require 'PHPMailer/src/Exception.php'; 
require 'PHPMailer/src/PHPMailer.php'; 
require 'PHPMailer/src/SMTP.php'; 
 
$mail = new PHPMailer(true);   // error coming here
 
$mail->isSMTP();                      // Set mailer to use SMTP 
$mail->Host = 'smtp.gmail.com';       // Specify main and backup SMTP servers 
$mail->SMTPAuth = true;               // Enable SMTP authentication 
$mail->Username = 'user@gmail.com';   // SMTP username 
$mail->Password = 'gmail_password';   // SMTP password 
$mail->SMTPSecure = 'tls';            // Enable TLS encryption, `ssl` also accepted 
$mail->Port = 587;                    // TCP port to connect to 
 
// Sender info

Thanks

P粉921165181
P粉921165181

reply all(1)
P粉734486718

When you use composer, just autoload (it does all the "need" work)

include_once 'vendor/autoload.php'
use PHPMailer\PHPMailer\PHPMailer; 
use PHPMailer\PHPMailer\Exception;

// require 'PHPMailer/src/Exception.php'; 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template