Gửi email tự động khi tải trang (Send Email Automatically On Page Load)


問題描述

Gửi email tự động khi tải trang (Send Email Automatically On Page Load)

Is it possible using PHP/HTML/JS that when a user loads a 404 web page it automatically triggers an email to be sent to the web admin notifying them that the page was loaded and how the user got there (what was the page before and what did they click on that page to reach the 404 page.

I dont mean that it opens up the users email client, it should be clean and unobtrusive 


參考解法

方法 1:

In order to do do this you would want to create a .php script which will send the email and server the page. Here is a quick walkthrough to set the custom 404 page in Apache.

In order to send the email, you'll want to use PHP's mail() function. You can read about it here. 

After saying this, strongly consider before you do it. I repeat... strongly. Web crawlers and vulnerability scanners are constantly hitting 404 pages... if one happens to hit your site do you really want your admin to get thousands of emails? You would have to find ways to avoid all these cases and only send emails when a 'legitimate' 404 occurs. As well, sending these emails will occupy your server resources, which could make it much easier for a DOS attack to take down your site (overload it by having it send so many emails).

方法 2:

Yes. It is possible. Take a look at php's mail().

(by ExhaustedNick MitchinsonAiias)

參考文件

  1. Send Email Automatically On Page Load (CC BY‑SA 3.0/4.0)

#http-status-code-404 #email #PHP






相關問題

PHP在simplexml print_r上返回頁面錯誤 (PHP returning page error on simplexml print_r)

Apache Camel 和 CXF:多個 cxf:rsServer 標籤 .. 這可能嗎? (Apache Camel and CXF: Mutlitple cxf:rsServer tags .. is this possible?)

Penyiapan situs MSM 5 dengan pengalihan halaman 404 umum (MSM 5 site setup with a common 404 page redirect)

Успадкоўванне кантролера ASP.NET MVC 4 (ASP.NET MVC 4 controller inheritance)

Laravel Put Route Giving 404 錯誤 (Laravel Put Route Giving 404 Error)

WordPress 404 頁 (Wordpress 404 PAGE)

Gửi email tự động khi tải trang (Send Email Automatically On Page Load)

何時顯示“未找到記錄”頁面或返回 HTTP 404? (When to display "Record Not Found" Page or return HTTP 404?)

Breeze.js:處理空結果 (Breeze.js: Handling empty results)

如何從php中製作的404自定義頁面獲取用戶嘗試訪問的鏈接 (How to get the link that the user tried to visit, from a 404 custom page made in php)

Flask 文件上傳失敗並出現 404 錯誤 (Flask File Upload fails with 404 error)

如何在 ASP.NET 頁面中對超鏈接和內容進行變基? (How do you rebase hyperlinks and content in an ASP.NET page?)







留言討論