亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHPMailer 表單沒有錯誤或發送

PHPMailer 表單沒有錯誤或發送

PHP
泛舟湖上清波郎朗 2023-09-08 22:04:48
在 error_log 或頁面上沒有收到任何錯誤。錯誤日志肯定可以正常工作,就像我更改 require 'PHPMailer.php';為require 'PHPFailer.php';我得到的那樣PHP Fatal error:  require(): Faileddisplay_errors 設置為 trueerror_reporting 設置為E_ALL & ~E_NOTICEPHPMailer 6.1.7 - PHP 7.2PHPMailer.php 和 Exception.php 都位于根目錄中。當我剛剛發送到 /php/form_error.php 時,已注釋掉重定向。任何想法將不勝感激,謝謝。contact_post.php<?php    /*    THIS FILE USES PHPMAILER INSTEAD OF THE PHP MAIL() FUNCTION    */    use PHPMailer\PHPMailer\PHPMailer;    use PHPMailer\PHPMailer\Exception;        require 'PHPMailer.php';    require 'Exception.php';        /*    *  CONFIGURE EVERYTHING HERE    */        // an email address that will be in the From field of the email.    $fromEmail = '[email protected]';    $fromName = 'Info domain';        // an email address that will receive the email with the output of the form    $sendToEmail = '[email protected]';    $sendToName = 'Info domain';        // subject of the email    $subject = 'New message from contact form';        // form field names and their translations.    // array variable name => Text to appear in the email    $fields = array('name' => 'Name', 'surname' => 'Surname', 'phone' => 'Phone', 'email' => 'Email', 'message' => 'Message');        // message that will be displayed when everything is OK :)    $okMessage = 'Contact form successfully submitted. Thank you, I will get back to you soon!';        // If something goes wrong, we will display this message.    $errorMessage = 'There was an error while submitting the form. Please try again later';    
查看完整描述

1 回答

?
慕俠2389804

TA貢獻1719條經驗 獲得超6個贊

根據我的評論,當出現問題時你沒有做任何事情,所以沒有什么可看的。


要查看實際出了什么問題,請在出現問題時輸出一些有用的信息,例如:


catch (\Exception $e)

{

    $responseArray = ['type' => 'danger', 'message' => $e->getMessage()];

    var_dump($responseArray, $mail->ErrorInfo);

}

一件小事:


    if(!$mail->send()) {

        throw new \Exception('I could not send the email.' . $mail->ErrorInfo);

    }

沒有必要這樣做——PHPMailer 已經設置為拋出異常,所以這應該是:


$mail->send();


查看完整回答
反對 回復 2023-09-08
  • 1 回答
  • 0 關注
  • 99 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號