如何使PHPMailer在BlueHost上工作?

PHPMailer works well on GoDaddy and on my localhost; however, it doesn't work on Bluehost. I have tried everything. At the beginning it did partially work, i.e., it sent an email and I could activate the account, but I couldn't login. However, now it just shows a blank page or it shows a waiting sign. When it did partially work the $mail->SMTPDebug = SMTP::DEBUG_SERVER; gave a detailed report; however, I couldn't see any error in it. Now the browser simply shows a blank page or a waiting sign. Bluehost error_log file shows: PHP Fatal error: Uncaught Error: Class 'SMTP' not found in/home4/username/public_html/vendor_email.php:23

这是我的代码:

use PHPMailer\PHPMailer\PHPMailer;
//use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

    // Load Composer's autoloader
    require './vendor/autoload.php';
    //require './classes/Config.php';

function send_email($email=null, $subject=null, $message=null, $header=null) {

$mail = new PHPMailer(true);

try {

//Server Settings
    $mail->SMTPDebug  = SMTP::DEBUG_SERVER;  
    $mail->isSMTP();                                            
    $mail->SMTPAuth   = true;                     
    $mail->SMTPAutoTLS = true;   
    $mail->SMTPSecure = 'tls';  
    $mail->Host       = 'mail.mywebsite.com'; 
    $mail->Port       = ' 465'; 
    $mail->Username   = 'autoreply@mywebsite.com';                    
    $mail->Password   = 'secret'; 

   //Recipients
    $mail->setFrom('autoreply@mywebsite.com');
    $mail->addAddress($email); 

    // Content
    $mail->isHTML(true);                                
    $mail->Subject = $subject;
    $mail->Body    = $message; 

 $mail->send();
 echo 'Message has been sent';
  } catch (Exception $e) {
 echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}

我将此代码更改为多个设置,类似于在Stackoverflow,YouTube上发布的设置,以及在GoDaddy上的设置。另外,我重新安装了composer并将PHPMailer从6.0更新到最新版本6.5;但是,没有任何效果。

评论