列表项
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Username = 'xxxxxxxx@gmail.com';
$mail->Password = 'xxxxxxxxxx';
$mail->setFrom($_POST['email'],$_POST['name']);
$mail->addAddress('xxxxxxxxxx@gmail.com');
$mail->addReplyTo($_POST['email'],$_POST['name']);
$mail->isHTML(true);
$mail->Subject='Intending to: '.$_POST['option'];
$mail->Body='<h1 align=center> Name :'.$_POST['name'].'<br>Email: '.$_POST['email'].
'<br>Message: '.$_POST['text'].'</h1>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
$result="Something went wrong. Please try again.";
}
else {
$result="Thank You ".$_POST['name']." for contacting us. We'll get back to you soon!";
}
}
?> //我得到的错误是致命错误:未捕获的错误:在/storage/ssd4/215/7577215/public_html/index.php:31中找不到类'PHPMailer'堆栈跟踪:#0 {main}丢在/ storage /中ssd4 / 215/7577215 / public_html / index.php,第5行
///仅当文件在服务器上,在localhost上发送邮件时,这种情况才会发生。
答案 0 :(得分:0)
您还必须上传PHPMailer类,而不仅仅是您的脚本。
您还使用了过时的PHPMailer版本;从GitHub获取最新版本。