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
When you use composer, just autoload (it does all the "need" work)