【问题标题】:Not found PHPMailer in PHPMailer new versionPHPMailer新版本中未找到PHPMailer
【发布时间】:2018-05-02 10:38:17
【问题描述】:

以下代码是PHP:

class Email
{
    private $mail,$to,$subject,$body;
    function __construct()
    {
        require_once "phpmailer1/src/PHPMailer.php";
        require_once "phpmailer1/src/SMTP.php";
        require_once "phpmailer1/src/POP3.php";
        $this->mail = new PHPMailer(true);
        $this->mail->isSMTP();
        $this->mail->Host = "smtp.gmail.com";
        $this->mail->Username = "emailaddress";
        $this->mail->Password = "password";
        $this->mail->SMTPSecure = "tls";
        $this->mail->Port = 587;
        $this->to = "0";
        $this->subject = "0";
        $this->body = "0";
        $this->mail->SMTPAuth = true;
        $this->mail->setFrom("new address email","hello");
        $this->mail->CharSet = "utf-8";
        $this->mail->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
        );
    }
    function ToEmail($getmail)
    {
        $this->to = $getmail;
    }
    function SubjectMail($submail)
    {
        $this->subject = $submail;
    }
    function BodyMail($bodymail)
    {
        $this->body = $bodymail;
    }
    function Send()
    {
        if($this->to != "0" && $this->subject != "0" && $this->body != "0")
        {
            $this->mail->addAddress($this->to,"hello");
            $this->mail->subject = $this->subject;
            $this->mail->msgHTML($this->body);
            if($this->mail->send())
            {
                echo "Email Send";
            }
            else
            {
                echo "Email Not Send";
            }
        }
        else
        {
            echo "230";
        }
    }
};

我想使用新版本的PHPMailer,但是当我想运行它时,我看到了

致命错误:未捕获的错误:在 C:\xampp\htdocs\xampp\khunehyab\email\mainemail.php:13 中找不到类“PHPMailer”:13 堆栈跟踪:#0 C:\xampp\htdocs\xampp\khunehyab\ email\mainemail.php(69): Email->__construct() #1 {main} 抛出我该怎么办??请帮帮我,我的 PHPMailer 是 v6.0.1

【问题讨论】:

标签: php phpmailer


【解决方案1】:

您需要使用 PHPMailer\PHPMailer\PHPMailer 的完全限定类名 (FQCN),或者将其导入您的命名空间,并在文件顶部使用 use PHPMailer\PHPMailer\PHPMailer;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-15
    • 2022-01-21
    • 1970-01-01
    相关资源
    最近更新 更多