ASP automatically sends emails when a webpage does not exist

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.