When making a website, there are usually some wrong actions for visitors or the defects of our website. cause a non-existent page to be accessed, there will be 404 error messages, if the enthusiastic visitors may send you an e-mail alert you, most of the time is not the visitors will send us an e-mail. Use ASP to do a practical program, when the user access to 404 error message when the system will automatically send an e-mail to us, so don't worry, the production code is as follows:
The following is a reference fragment:
<% @language = "VBScript"%>
<% Option Explicit%>
<%
Dim strpage, Strreferer, strmessage
Dim OBJSMTP
' Log the offending page
Strpage = Request.ServerVariables ("Http_url")
' Log the Referer
Strreferer = Request.ServerVariables ("Http_referer")
' Set up ' email component
Set objsmtp = Server.CreateObject ("Jmail.message")
Objsmtp.from = "You@yourdomain.com"
Objsmtp.fromname = "Your Domain"
Objsmtp.subject = "404 Error Logged"
Objsmtp.addrecipient ("you@yourdomain.com")
' Write the message http://www.bianceng.cn/
strmessage = "Requested page:" & strpage & VbCrLf & VbCrLf
If strreferer <> "" Then
strmessage = strmessage & "Referer:" & Strreferer
Else
strmessage = strmessage "The Visitor typed"
End If
Objsmtp.body = strmessage
' Send the message
Objsmtp.send ("mail.jzxue.com")
' Tidy up
Objsmtp.clearrecipients
Objsmtp.close ()
Set objsmtp = Nothing
%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en"
"Http://www.w3.org/TR/html4/strict.dtd" >
<title>404 Page not found</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<p>
Appropriate message is here.
</p>
</body>