gpt4 book ai didi

php - fatal error : Class 'PHPMailer' not found

转载 作者:IT王子 更新时间:2023-10-28 23:58:37 26 4
gpt4 key购买 nike

  • 我试过:include_once('C:\Inetpub\wwwroot\php\PHPMailer\PHPMailerAutoload.php');

Fatal error: Class 'PHPMailer' not found in C:\Inetpub\wwwroot\php\index.php on line 151

我将 PHPMailerAutoload.php 放在与我的脚本相同的目录中。

有人可以帮我解决这个问题吗?

最佳答案

所有答案现在都已过时。大多数当前版本(截至 2018 年 2 月)不再具有自动加载功能,PHPMailer 应按如下方式初始化:

<?php

require("/home/site/libs/PHPMailer-master/src/PHPMailer.php");
require("/home/site/libs/PHPMailer-master/src/SMTP.php");

$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP(); // enable SMTP

$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "xxxxxx";
$mail->Password = "xxxx";
$mail->SetFrom("xxxxxx@xxxxx.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("xxxxxx@xxxxx.com");

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>

关于php - fatal error : Class 'PHPMailer' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28906487/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com