本文介绍了致命错误:找不到类"PHPMailer"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 我尝试过:
include_once('C:\Inetpub\wwwroot\php\PHPMailer\PHPMailerAutoload.php');
我将PHPMailerAutoload.php
放在与脚本相同的目录中.
I place the PHPMailerAutoload.php
in the same directory as my script.
有人可以帮我吗?
推荐答案
所有答案现在都已过时.最新版本(截至2018年2月)不再具有自动加载功能,PHPMailer应该按以下方式初始化:
all answers are outdated now. Most current version (as of Feb 2018) does not have autoload anymore, and PHPMailer should be initialized as follows:
<?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("[email protected]");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("[email protected]");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>
这篇关于致命错误:找不到类"PHPMailer"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!