簡體   English   中英

是否可以通過帶有error_log()的SMTP發送郵件?

[英]is it possible to send mail via SMTP with error_log()?

我正在使用以下錯誤處理功能,如果該站點處於活動狀態( $live==TRUE ),它將通過電子郵件將錯誤發​​送給$admin_email 我的主機現在需要SMTP身份驗證。 我是否假設必須刪除對error_log()的調用並使用PEAR郵件包或PHPMailer發送郵件是否正確?

// Create the error handler.
function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) {

global $live, $admin_email;

// Build the error message.
$message = "An error occurred in script '$e_file' on line $e_line: \n<br />$e_message\n<br />";

// Add the date and time.
$message .= "Date/Time: " . date('n-j-Y H:i:s') . "\n<br />";

// Append $e_vars to the $message.
$message .= "<pre>" . print_r ($e_vars, 1) . "</pre>\n<br />";

if ($live) { // Don't show the specific error.

    echo('<p>sending email</p>');

    error_log ($message, 1, $admin_email); // Send email.

    // Only print an error message if the error isn't a notice.
    if ($e_number != E_NOTICE) {
        echo '<div id="Error">A system error occurred. An administrator has been notified. We apologize for the inconvenience.</div><br />';
    }

} else { // Development (print the error).
    echo '<div id="Error">' . $message . '</div><br />';
}

return FALSE;

} // End of my_error_handler() definition.

郵件功能不使用授權。 我認為在Windows上,您可以將php.ini文件中的php設置為默認使用smtp。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM