When creating a website, a visitor may encounter some incorrect operations or website defects, resulting in a webpage that does not exist being accessed. In this case, the 404 error message is displayed, an enthusiastic visitor may send you an email prompting you that most of the time the visitor will not send us an email. Use ASP to create a utility program. When a user accesses a 404 error message, the system will automatically send an email to us, so you don't have to worry about it. The Code is as follows:
The following is a reference clip:
<% @ 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 = "you@yourdomain.com"
Objsmtp. fromname = "your domain"
Objsmtp. Subject = "404 error logged"
Objsmtp. addrecipient ("you@yourdomain.com ")
'Write the message http://soft.knowsky.com/
Strmessage = "requested page:" & strpage & 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 <P>
Appropriate message here.
</P>
</Body>
</Html>