我保留此消息:2019-07-06 10:38:33 SMTP错误:无法连接到服务器:(0) SMTP connect()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 抱歉,邮件未发送
在c:// ...中找不到AND类“ phpmailer”; 我需要帮助
<?php
$mailTo = $_POST['email'];
$mailSub = $_POST['subject'];
$mailBody = $_POST['message'];
require_once "PHPMailer/PHPMailer.php";
require_once "PHPMailer/SMTP.php";
require_once "PHPMailer/Exception.php";
mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 3;
$mail->SMTPAuth=true;
$mail->SMTPSecure = 'ssl';
$mail->Host ="smtp.gmail.com";
$mail->Port = 465; // or 587 TLS
$mail->IsHTML(true);
$mail->Username ="XXX@gmail.com";
$mail->Password ="XXX";
$mail->SetFrom('XXX@gmail.com');
$mail->Subject =$mailSub;
$mail->Body = $mailBody;
$mail->AddAddress($mailTo);
if(!$mail->Send()){
echo "sorry mail not send";
}else{
echo "sent!";
}
?>