当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP实现不存在的网页就自动发送邮件

ASP
通过ASP与ACCESS数据库建立连接(附源码)(1)
通过ASP与ACCESS数据库建立连接(附源码)(2)
通过ASP与ACCESS数据库建立连接(附源码)(3)
关于页面局部刷新例程
仿照CHINAASP论坛中TOP10写的部分显示代码
用ASP做一个记事本编缉器(附源码)
让您的主页支持各种浏览设备(ASP+篇)(下)
用ASP开发一个在线考试程序(五)
用ASP开发一个在线考试程序(六)
用ASP开发一个在线考试程序(七)
用ASP开发一个在线考试程序(八)
用ASP开发一个在线考试程序(九)
用SQL Server为Web浏览器提供图像1
用SQL Server为Web浏览器提供图像2
用SQL Server为Web浏览器提供图像3(end)
制作一个个人搜索引擎(源码)
制作一个简单的服务器端控制
用Access制作一个功能完善的论坛(源程序)
广告播放和跟踪系统的制作
动态广告管理程序制作例子

ASP实现不存在的网页就自动发送邮件


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 70 ::
收藏到网摘: n/a

我们在制作网站的时候,通常会有当访客的一些错误操作或我们网站本身的缺陷,造成某个不存在的页面被访问,这时会出现404错误提示信息,如果是热心的访客可能会给你发一封邮件提示你,当时大部分时候是访客不会给我们发邮件的。今天给大家介绍的这个程序是当我们的网站出现404错误提示时自动发送一封邮件给我们,代码如下:

以下为引用的内容:
<% @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
    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>
<% @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
    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>