Jump to content

Recommended Posts

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 by vikaspa
Link to comment
https://forums.phpfreaks.com/topic/324786-phpmailer-for-php-8-not-working/
Share on other sites

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.

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  ;

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.