ASP to implement a Non-existent Web page to automatically send mail

Source: Internet
Author: User
Tags mail servervariables

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>

Related Article

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.