首页 > 解决方案 > PHPMailer 函数问题

问题描述

我的 php 邮件程序有问题,但无法正常工作,但已创建令牌。只是显示味精'出了点问题'......请帮我找出问题我的代码:

if(isset($_POST['action']) && $_POST['action'] == 'forgot'){
    $email = $user->test_input($_POST['email']);

    $user_found = $user->currentUser($email);

    if($user_found != null){
        $token = uniqid();
        $token = str_shuffle($token);

        $user->forgot_password($token,$email);
        try{
            $mail->isSMTP();
            $mail->Host = 'smtp.gmail.com';
            $mail->SMTPAuth = true;
            $mail->Username = Database::USERNAME;
            $mail->Password = Database::PASSWORD;
            $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
            $mail->Port = 587;

            $mail->setFrom(Database::USERNAME,'HuntedZone');
            $mail->addAddress($email);

            $mail->isHTML(true);
            $mail->Subject = 'Reset Password';
            $mail->Body = '<h3>Click the Below link to reset your password.<br><a href="http://localhost/user-system/reset-pass.php?email='.$email.'&token='.$token.'">http://localhost/user-system/reset-pass.php?email='.$email.'&token='.$token.'</a><br>Regards<br>HuntedZone!</h3>';

            $mail->send();
            echo $user->showMessage('success','We Have send you the reset link in your e-mail ID, Please Check your e-mail');
        }catch(Exception $e){
            echo $user->showMessage('danger','Something went wrong Please try again Later!');
        }

    }else{
        echo $user->showMessage('info','This E-mail is not Registered!');
    }
}

标签: phpoopphpmailer

解决方案


推荐阅读