简体   繁体   中英

Class "PHPMailer\PHPMailer\PHPMailer" not found

I'm using CodeIgniter 4 and I'm trying add PHPMailer to my project via a composer:

composer require phpmailer/phpmailer

在此处输入图像描述

My Controller:

<?php

namespace App\Controllers;

use CodeIgniter\Controller;
use App\Models\IssueModel;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

class Issues extends Controller {

    public function create() {
        if ($this->request->getMethod() == 'post') {
            .... // some code here
                $issueModel = new IssueModel();

                $mail = new PHPMailer(true);

                $mail->SMTPDebug = SMTP::DEBUG_SERVER;
                $mail->isSMTP();
                $mail->Host       = 'mai';
                $mail->SMTPAuth   = true;
                $mail->Username   = 'noreply';
                $mail->Password   = 'pass';
                $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
                $mail->Port       = 587;

                ..... // some code here
    }

}

And I have an error:

Class "PHPMailer\PHPMailer\PHPMailer" not found

Where is a problem?

Based on issue on this https://github.com/PHPMailer/PHPMailer/issues/1703

You should run composer dump-autoload

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