Php 未定义属性:控制器::$Mail\u codeigniter中的库

Php 未定义属性:控制器::$Mail\u codeigniter中的库,php,codeigniter-3,Php,Codeigniter 3,我正在集成phpmailer,但无法加载我的库这里发生了什么 我有一个问题,无法在控制器中加载我的库 我遇到了这个错误: 消息:未定义属性:欢迎::$Mail 我面临这些问题,请提出建议 严重性:通知 消息:未定义属性:欢迎::$Mail 文件名:controllers/Welcome.php 电话号码:352 库文件名为Mail.php 类名和文件名必须匹配,但获取错误 <?php defined('BASEPATH') OR exit('No direct script acc

我正在集成
phpmailer
,但无法加载我的库这里发生了什么 我有一个问题,无法在控制器中加载我的库

我遇到了这个错误:

消息:未定义属性:欢迎::$Mail

我面临这些问题,请提出建议

严重性:通知

消息:未定义属性:欢迎::$Mail

文件名:controllers/Welcome.php

电话号码:352

库文件名为
Mail.php

类名和文件名必须匹配,但获取错误

<?php
    defined('BASEPATH') OR exit('No direct script access allowed');
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;
    class Mail
    {
        public function __construct(){
            log_message('Debug', 'PHPMailer class is loaded.');
        }

        public function load(){
            // Include PHPMailer library files
            require_once APPPATH.'third_party/phpmailer/src/Exception.php';
            require_once APPPATH.'third_party/phpmailer/src/PHPMailer.php';
            require_once APPPATH.'third_party/phpmailer/src/SMTP.php';

            $mail = new PHPMailer\PHPMailer\PHPMailer(true);
            return $mail;
        }
    }

    ?>

欢迎控制器代码[Welcome.php]

<?php
    defined('BASEPATH') OR exit('No direct script access allowed');

    class Welcome extends CI_Controller {

        public function __construct()
        {
            parent::__construct();

            $this->load->library('Mail');

        } 

        function email_user($full_name, $email, $passwordplain){

            $this->load->library('Mail'); // error show this line 

            $mail = $this->Mail->load();

            $mail->isSMTP();
            $mail->Host     = 'ssl://smtp.gmail.com';
            $mail->SMTPAuth = true;
            $mail->Username = 'test@gmail.com';
            $mail->Password = 'password';
            $mail->SMTPSecure = 'tls';
            $mail->Port     = 465;

            $mail->setFrom('example@gmail.com');
            $mail->addAddress($email);
            $mail->addCC('example@gmail.com');
            $mail->addBCC('example@gmail.com');
            $mail->Subject = 'Send Email via SMTP using password';
            $mail->isHTML(true);
            $mail_message = "<h1>Send HTML Email using SMTP in CodeIgniter</h1>
            <p>This is a test email sending using SMTP mail server with PHPMailer.</p>";
            $mail_message = 'Dear ' . $full_name. ',' . "\r\n";
            $mail_message .= 'Thanks for contacting regarding to forgot password,<br> Your <b>Password</b> is <b>' . $passwordplain . '</b>' . "\r\n";
            $mail_message .= '<br>Please Update your password.';
            $mail_message .= '<br>Thanks & Regards';
            $mail_message .= '<br>Your company name';
            $mail->Body = $mail_message;


            if(!$mail->send()){
                echo 'Message could not be sent.';
                echo 'Mailer Error: ' . $mail->ErrorInfo;
            }else{
                echo 'Message has been sent';
            }
        }
    }
?>

尝试以下代码:

$this->load->library('mail');

$mail = $this->mail->load();