我尝试过的
include_once('C:\Inetpub\wwwroot\php\PHPMailer\PHPMailerAutoload.php');
我将
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("[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";
}
?>
关于php - 致命错误: Class 'PHPMailer' not found,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28906487/