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

使用jmail组件发送邮件: 制作网站的时候通常会有当访客的一些错误操作或我们网站本身的缺陷,造成某个不存在的页面被访问,这时会出现404错误提示信息,如果是热心的访客可能会给你发一封邮件提示你,当时大部分时候是访客不会给我们发邮件的。用ASP做一个实用的程序,当用户访问出现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 = ""
    objSMTP.FromName = "Your Domain"
    objSMTP.Subject = "404 Error Logged"
    objSMTP.AddRecipient("")
    ' Write the message http://www.361du.net
    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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值