vikaspa Posted October 13 Share Posted October 13 (edited) Dear Respected i had installed phpmailer using composer logged in to cpanel used Terminal to install phpmailer command (@terminal) composer require phpmailer/phpmailer (help found in https://packagist.org/packages/phpmailer/phpmailer ) After installation, I had used following php code to send email require('vendor/autoload.php'); require "vendor/phpmailer/phpmailer/src/PHPMailer.php"; require "vendor/phpmailer/phpmailer/src/OAuth.php"; require "vendor/phpmailer/phpmailer/src/SMTP.php"; require "vendor/phpmailer/phpmailer/src/POP3.php"; require "vendor/phpmailer/phpmailer/src/Exception.php"; // use vendor/phpmailer/phpmailer/src //require "vendor/phpmailer/phpmailer/src/PHPMailer"; $mail = new PHPMailer ; $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; Error Uncaught Error: Class "PHPMailer" not found <in path here> pls help me to solve this issue Edited October 13 by vikaspa Quote Link to comment Share on other sites More sharing options...
requinix Posted October 13 Share Posted October 13 The only require you need is for vendor/autoload.php. Remove the others. "PHPMailer" is the name of the class, yes, but it also exists in a namespace. Do you have at least this particular use statement use PHPMailer\PHPMailer\PHPMailer; at the top of your file? I'm grabbing that directly from the packagist.org page you linked to. Quote Link to comment Share on other sites More sharing options...
vikaspa Posted October 13 Author Share Posted October 13 Thanks for reply i tried but resulted in syntax error, unexpected token "use" use PHPMailer\PHPMailer\PHPMailer; require 'vendor/autoload.php'; //Create a new PHPMailer instance $mail = new PHPMailer(); /* require "vendor/phpmailer/phpmailer/src/PHPMailer.php"; require "vendor/phpmailer/phpmailer/src/OAuth.php"; require "vendor/phpmailer/phpmailer/src/SMTP.php"; require "vendor/phpmailer/phpmailer/src/POP3.php"; require "vendor/phpmailer/phpmailer/src/Exception.php"; */ // use vendor/phpmailer/phpmailer/src // require "vendor/phpmailer/phpmailer/src/PHPMailer"; //$mail = new PHPMailer ; Quote Link to comment Share on other sites More sharing options...
Barand Posted October 13 Share Posted October 13 When something is "unexpected" the cause is usually whatever came before it. But you haven't shown us that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.