简体   繁体   中英

Can't solve error PHPmailer

When i register and account with my loginform and its supposed to send a confirmation email it gives me this error:

Fatal error: Uncaught Error: Class 'SMTP' not found in C:\xampp\htdocs\login\mailer\class.phpmailer.php:1479
Stack trace:
#0 C:\xampp\htdocs\login\mailer\class.phpmailer.php(1562): PHPMailer->getSMTPInstance()
#1 C:\xampp\htdocs\login\mailer\class.phpmailer.php(1499): PHPMailer->smtpConnect(Array)
#2 C:\xampp\htdocs\login\mailer\class.phpmailer.php(1336): PHPMailer->smtpSend('Date: Fri, 3 Ma...', 'This is a multi...')
#3 C:\xampp\htdocs\login\mailer\class.phpmailer.php(1214): PHPMailer->postSend()
#4 C:\xampp\htdocs\login\class.user.php(106): PHPMailer->send()
#5 C:\xampp\htdocs\login\signup.php(43): USER->send_mail('Rainier.laan@ho...', 'Hello Rainier, ...', 'Confirm Registr...')
#6 {main} thrown in C:\xampp\htdocs\login\mailer\class.phpmailer.php on line 1479

I looked up what was on line 1479 and it was this:

if (!is_object($this->smtp)) {
        $this->smtp = new SMTP;
    }

I cant see what the error is. Im new to this. Can you guys help me?

As per the documentation

Using PHPMailer's own autoloader

Not so long ago, PHPMailer changed the way that it loaded classes so that it was more compatible with composer, many frameworks, and the PHP PSR-0 autoloading standard. Note that because we support PHP back to version 5.0, we cannot support the more recent PSR-4 standard, nor can we use namespaces. Previously, PHPMailer loaded the SMTP class explicitly, and this causes problems if you want to provide your own implementation. You may have seen old scripts doing this:

require 'class.phpmailer.php';

If you do only that, SMTP sending will fail with a Class 'SMTP' not found error . You need to either explicitly include the class.smtp.php file (read the README for info on which files you need), or use the recommended approaches of using composer or the supplied autoloader, like this:

require 'PHPMailerAutoload.php';

Check if you have download all the project files. The SMTP class code is defined into the PHPMailer project, in this file .

If you downloaded PHPMailer with composer, ensure you have a line like require_once 'vendor/autoload.php . Otherwise, check if you have a line like require_once 'mailer/PHPMailerAutoload.php before to use the PHPMailer classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM