When making a website, there will usually be some incorrect operations by visitors or defects in our website itself, causing a non-existent page to be accessed. At this time, a 404 error message will appear. If it is an enthusiastic visitor, it may send you a message. An email to remind you that most of the time visitors will not send us emails. Use ASP to make a practical program. When the user accesses and a 404 error message appears, the system will automatically send an email to us, so there is no need to worry. The production code is as follows:
The following is a quoted 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 the email component
Set objSMTP = Server.CreateObject("JMail.Message")
objSMTP.From = " [email protected] "
objSMTP.FromName = "Your Domain"
objSMTP.Subject = "404 Error Logged"
objSMTP.AddRecipient(" [email protected] ")
' Write the message http://soft.downcodes.com/
strMessage = "Requested page: " & strPage & vbCrLf & vbCrLf
If strReferer <> "" Then
strMessage = strMessage & "Referer: " & strReferer
Else
strMessage = strMessage "The visitor typed the address in"
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 ">
<html lang="en">
<head>
<title>404 Page Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<h1>404 Page Not Found Error</h1>
<p>
Appropriate message here.
</p>
</body>
</html>