【问题标题】:Uncaught Error: Class 'PHPMailer\PHPMailer\Exception' not found in C未捕获的错误:在 C 中找不到类 'PHPMailer\PHPMailer\Exception'
【发布时间】:2018-07-25 22:33:43
【问题描述】:

由于错误,我无法收到确认电子邮件。这是我的 PhpMailer 错误就行了。

致命错误:未捕获的错误:在 C:\xampp\htdocs\Web\PHPMailer\PHPMailer.php:1703 中找不到类 'PHPMailer\PHPMailer\Exception' 堆栈跟踪:#0 C:\xampp\htdocs\Web\ PHPMailer\PHPMailer.php(1515): PHPMailer\PHPMailer\PHPMailer->mailSend('Date: Wed, 25 J...', '\r\n ...') #1 C:\xampp\htdocs\pificy \PHPMailer\PHPMailer.php(1352): PHPMailer\PHPMailer\PHPMailer->postSend() #2 C:\xampp\htdocs\Web\1r.php(43): PHPMailer\PHPMailer\PHPMailer->send() #3 {main} 在第 1703 行的 C:\xampp\htdocs\pificy\PHPMailer\PHPMailer.php 中抛出。

下面是我遇到错误的那一行。我该怎么办?

if (!$result) {
throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL);
    }

更具体地说,这是我的注册文件代码:

<?php
$msg = "";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

if (isset($_POST['submit'])) {
    $con = new mysqli('localhost', 'Owner', '', 'Pificy');

$username = $con->real_escape_string($_POST['username']);
$email = $con->real_escape_string($_POST['email']);
$password = $con->real_escape_string($_POST['password']);
$cPassword = $con->real_escape_string($_POST['cPassword']);

if ($username == "" || $email == "" || $password != $cPassword)
        $msg = "Please check your inputs!";
else {
$sql = $con->query("SELECT id FROM users WHERE email='$email'");
if ($sql->num_rows > 0) {
$msg = "Email already exists in the database!";
} else {
$token 'qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM0123456789!$/()*';
$token = str_shuffle($token);
$token = substr($token, 0, 10);

$hashedPassword = password_hash($password, PASSWORD_BCRYPT);

$con->query("INSERT INTO users (username,email,password,isEmailConfirmed,token)
VALUES ('$username', '$email', '$hashedPassword', '0', '$token');
            ");

include_once "PHPMailer/PHPMailer.php";

$mail = new PHPMailer();
$mail->setFrom('NotForUtoKnow@gmail.com');
$mail->addAddress($email, $username);
$mail->Subject = "Please verify email!";
$mail->isHTML(true);
$mail->Body = "
Please click on the link below:<br><br>

<a href='http://Upcoming.com/Upcoming/confirm.php?email=$email&token=$token'>Click Here</a>
            ";

if ($mail->send())
$msg = "You have been registered! Please verify your email!";
            else
$msg = "Something wrong happened! Please try again!";
}
}
}
?>

【问题讨论】:

    标签: php phpmailer


    【解决方案1】:

    就像你包括在内:

    include_once "PHPMailer/PHPMailer.php";
    

    您还需要包含 Exception.php:

    include_once "PHPMailer/Exception.php";
    

    【讨论】:

    • 我得到一个短语错误是不是像 PHPMailer/Exception.php;
    • 或使用 PhpMailer\Exception.php
    • Nvm,我明白了
    • 现在我无法注册,因为我收到一条错误消息:“出了点问题,再试一次。”
    • 如果您使用从 GitHub 下载的 tarball(而不是使用 composer),路径可能类似于 PHPMailer/src/PHPMailer.php
    猜你喜欢
    • 1970-01-01
    • 2020-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 2016-06-10
    相关资源
    最近更新 更多