ASP实现404错误时自动发邮件管理员
from:http://429006.com/article/Technology/1461.htm
实现的效果:
当访问出现404错误提示信息的时候系统会自动发一封邮件给管理员,这样就不必担心了也有不能访问的死链接了
把下面的带嵌入到404页面之后,设置好中间的帐号和密码。
代码如下:
实现的效果:
当访问出现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 = "you@yourdomain.com"
objSMTP.FromName = "Your Domain"
objSMTP.Subject = "404 Error Logged"
objSMTP.AddRecipient("you@yourdomain.com")
' 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.163.com")
' Tidy up
objSMTP.ClearRecipients
objSMTP.Close()
Set objSMTP = Nothing
%>
<%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
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.163.com")
' Tidy up
objSMTP.ClearRecipients
objSMTP.Close()
Set objSMTP = Nothing
%>