[英]Why am I getting an error in the code from PHPMailer?
只有一个错误(未定义类型'PHPMailer\PHPMailer\PHPMailer')。 在这一行中:$mail = new PHPMailer(TRUE);。 我尝试使用作曲家手动安装,但没有任何帮助。
<?php
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'vendor/autoload.php';
if (isset($_POST['password-reset-token']) && $_POST['email']) {
include "connect.php";
require_once('phpmail/PHPMailerAutoload.php');
$mail = new PHPMailer(TRUE);
$mail->CharSet = "utf-8";
$mail->IsSMTP();
PHPMailerAutoload.php
是多年前从 PHPMailer 中删除的一个非常古老的文件。 您不应该使用它,它很可能会干扰您的代码。 让 composer 为您处理 class 加载 - 这就是它的用途。 我建议获取最新版本,并将您的代码基于 PHPMailer 提供的示例,并阅读有关如何加载它和创建实例的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.