当前位置: 首页 > 图文教程 > 网络编程 > ASP > 出现404页面错误的自动发送邮件的代码

ASP
实例详解ASP中断开记录集的使用方法
代码指导用ASP木马实现FTP和解压缩
防范脚本入侵,你做好准备了吗?
ASP中检查没有数据提交的页面
ASP程序代码执行时间统计类
ASP实现将长的标题用省略号收尾
ASP常用代码剪辑
在ASP中利用“正则表达式” 对象实现UBB风格的论坛
ASP批量生成静态页
ASP生成柱型体,折线图,饼图源代码
马克斯电影站生成Rss Feed的代码
ASP怎么谈到应用到类的?
ASP:判断访问是否来自搜索引擎的函数
ASP代码:rs.open语句详细说明
用asp自动解析网页中的图片地址
ASP:True or False,明明白白你的If语句流程
ASP实现在提交表单到数据库的同时发邮件通知
“Web 匿名用户”帐户密码的位置
ASP分页效果之优化
使用新云cms过程中的问题总结

ASP 中的 出现404页面错误的自动发送邮件的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-12-06   浏览: 144 ::
收藏到网摘: 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.webjx.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>