使用PHP Mailer版本6.0.6
我知道会回答类似的问题,但是我的情况有所不同。 我已经成功配置了脚本,它运行正常。我当时正在接收邮件,但突然间我没有任何变化,就开始向我抛出此错误。
错误
[Sun Nov 25 21:49:37.852920 2018] [:error] [pid 2060:tid 780] [client ::1:59300]
PHP Fatal error: Uncaught Error: Class 'PHPMailer\\PHPMailer\\Exception' not found in E:\\TCi\\htdocs\\sdresidency\\website\\plugins\\PHPMailer\\PHPMailer.php:1920\nStack trace:\n#0 E:\\TCi\\htdocs\\sdresidency\\website\\plugins\\PHPMailer\\PHPMailer.php(1774): PHPMailer\\PHPMailer\\PHPMailer->smtpConnect(Array)\n#1 E:\\TCi\\htdocs\\sdresidency\\website\\plugins\\PHPMailer\\PHPMailer.php(1516): PHPMailer\\PHPMailer\\PHPMailer->smtpSend('Date: Sun, 25 N...', 'This is a multi...')\n#2
E:\\TCi\\htdocs\\sdresidency\\website\\plugins\\PHPMailer\\PHPMailer.php(1352): PHPMailer\\PHPMailer\\PHPMailer->postSend()\n#3
E:\\TCi\\htdocs\\sdresidency\\website\\newbooking.php(38): PHPMailer\\PHPMailer\\PHPMailer->send()\n#4 {main}\n thrown in
这是我用来发送邮件的配置
require_once "plugins/PHPMailer/PHPMailer.php";
require_once "plugins/PHPMailer/SMTP.php";
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP(); // enable SMTP
//Enable SMTP debugging.
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
//Set PHPMailer to use SMTP.
$mail->IsSMTP(); // enable SMTP
//Set SMTP host name
$mail->Host = "md-in-30.webhostbox.net";
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "<my mail id>";
$mail->Password = "<my password>";
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "tls";
//Set TCP port to connect to
$mail->Port = 587;
$mail->From = "<my mail id>";
$mail->FromName = "SD RESIDENCY";
$mail->addAddress("<receive mail id>", "name");
$mail->isHTML(true);
$mail->Subject = "NEW RESERVATION";
$mail->Body = $message;
$mail->AltBody = "No HTML Support";
if(!$mail->send())
{ $_SESSION['message'] = 'SOME ERROR OCCURED, PLEASE TRY AGAIN';}
else
{
$_SESSION['message'] = 'BOOKING COMPLETED SUCCESSFULLY';
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
我将html格式的邮件内容存储在$ message变量中。 我已经在这里和其他站点中尝试了所有已回答的问题,但是没有运气。任何帮助将不胜感激
答案 0 :(得分:1)
require_once "plugins/PHPMailer/PHPMailer.php";
替换为 require_once "./plugins/PHPMailer/PHPMailer.php";
composer require phpmailer/phpmailer
https://packagist.org/packages/phpmailer/phpmailer require 'vendor/autoload.php';