简体   繁体   English

PHPMailler错误(由于发生内部服务器错误,因此无法显示该页面。)

[英]PHPMailler error (The page cannot be displayed because an internal server error has occurred.)

I am trying to develop a form and send to email using phpmailer. 我正在尝试开发一种形式,并使用phpmailer发送到电子邮件。 sender email is Gmail. 发件人电子邮件是Gmail。 Below are my php code: 以下是我的PHP代码:

    <?php
    use PHPMailer\PHPMailer;
    use PHPMailer\Exception;

    require 'PHPMailer/PHPMailerAutoload.php';

    $mail = new PHPMailer(true);                             
    try {
        //Server settings
        $mail->SMTPDebug = 4;                                
        $mail->isSMTP();                                     
        $mail->Host = 'smtp.gmail.com'; 
        $mail->SMTPAuth = true;                             
        $mail->Username = 'thisismy@gmail.com';              
        $mail->Password = 'xxxxxxxx';                      
        $mail->SMTPSecure = 'tls';                           
        $mail->Port = 587;



    //Recipients
    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('receiver@gmail.com');     



    //Content
    $mail->isHTML(true);                                  
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
?>

I get this error The page cannot be displayed because an internal server error has occurred. 我收到此错误,因为发生了内部服务器错误,所以无法显示该页面。 *not using localhost *不使用本地主机

Read the PHPMailer readme that tells you how to load PHPMailer, and base your code on the examples provided. 阅读PHPMailer自述文件,该自述文件告诉您如何加载PHPMailer,并将代码基于提供的示例。 You are using PHPMailer 6 syntax, but trying to load it like PHPMailer 5, and the old autoloader does not exist, and trying to require it is a fatal error. 您正在使用PHPMailer 6语法,但尝试像PHPMailer 5一样加载它,并且旧的自动加载器不存在,并且尝试要求它是一个致命错误。

You would have found this out if you had read the most basic PHP debugging guide that would have told you to enable display of error messages, or to check your web server logs. 如果您已经阅读了最基本的PHP调试指南,该指南将告诉您启用错误消息显示或检查Web服务器日志,那么您将发现这一点。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于FastCGI进程意外退出,导致“由于发生内部服务器错误而无法显示该页面。” - “The page cannot be displayed because an internal server error has occurred.” as a result of The FastCGI process exited unexpectedly 没有任何启用错误报告的选项,克服了“由于发生内部服务器错误而无法显示该页面。” - Getting over the “The page cannot be displayed because an internal server error has occurred.” without any option to enable error reporting HTTP错误500.0-内部服务器错误该页面无法显示,因为发生了内部服务器错误 - HTTP Error 500.0 - Internal Server Error The page cannot be displayed because an internal server error has occurred 500-发生错误。 在joomla 2.5中 - 500 - An error has occurred. in joomla 2.5 cackphp具有同一页面的多个分页错误:发生内部错误 - cackphp multiple pagination with same page Error: An Internal Error Has Occurred dns_get_record(): 发生临时服务器错误。 - dns_get_record(): A temporary server error occurred. Nginx发生错误。 抱歉,您要查找的页面当前不可用 - Nginx An error occurred. Sorry, the page you are looking for is currently unavailable Joomla Backend - 切换到新主机后无法登录。 “发生了错误。 0无法打开写入日志的文件“ - Joomla Backend - Cannot login after switching to new host. “An error has occurred. 0 Cannot open file for writing log” Yii2-错误#1-发生内部服务器错误 - Yii2 - Error #1 - An internal server error occurred 贝宝沙盒:发生内部服务错误 - Paypal Sandbox: An internal service error has occurred
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM