PDA

View Full Version : JMail help


hughesmi
08-16-2008, 05:51 PM
Hi all. I need some help with this please. I cant see the problem

It is a Jmail setup but it is meant to check the HTTP reffer and also check for spammers. But I can get the spam part to work. It just says the mail was not sent, but it does get sent.

[code]

<%

strReferer = request.servervariables("HTTP_REFERER")
strServer = Replace(request.servervariables("SERVER_NAME"),"http://www.myhostname.co.uk","")
strClientIP = request.servervariables("REMOTE_ADDR")
strServerIP = request.servervariables("LOCAL_ADDR")

Set jmail = Server.CreateObject("JMail.Message")

' Form
jmail.From = "contact@myhostname.co.uk"
' To
jmail.AddRecipient "contact@myhostname.co.uk","Webadmim"
' Subject
jmail.Subject = "Test Email" 'get from form

' HTML Body
JMail.ContentType = "text/html"
JMail.body = "<HTML><BODY BGCOLOR=""#FFFFFF"" TEXT=""#000000"">"
JMail.body = JMail.body &"<PRE>"
JMail.body = JMail.body &"An e-mail enquiry has been made from your Website " & FormatDateTime(Now(),1) & " "
JMail.body = JMail.body &"<BR>"
JMail.body = JMail.body &"<BR>"
JMail.body = JMail.body &"Below is a summary of the email details."
JMail.body = JMail.body &"<HR>"
JMail.body = JMail.body &"Contact Name:" & request("yourName")
JMail.body = JMail.body &"<BR>"
JMail.body = JMail.body &"Email Address:" & Request("yourEmail")
JMail.body = JMail.body &"<BR>"
JMail.body = JMail.body &"Message:"& Request("message")
JMail.body = JMail.body &"<BR>"
JMail.body = JMail.body &"Reason:"& Request("reason")
JMail.body = JMail.body &"<BR>"
JMail.body = JMail.body &"Referral:"& Request("referral")
JMail.body = JMail.body &"<HR>"
JMail.body = JMail.body &"Server IP Address:"& strServerIP
JMail.body = JMail.body &"<BR>"
JMail.body = JMail.body &"User IP Address:"& strClientIP
JMail.body = JMail.body &"<BR>"
JMail.body = JMail.body &"</PRE>"
JMail.body = JMail.body &"</BODY></HTML>"

JMail.Priority = 3
JMail.AddHeader "Originating-IP", strClientIP

intComp = inStr(strReferer, strServer)
If intComp > 0 Then
blnSpam = False
Else
' Spam Attempt Block
blnSpam = True
End If

'This bit of code checks the referrer is correct, and if so sends the mail to the server.

If NOT blnSpam Then
JMail.Execute
strResult = "Mail Sent."
Else
strResult = "Mail Not Sent." & Jmail.log
End If

' Send to server
jmail.Send( "mail.myhostname.co.uk" )

'After outputting whatever text you want to tell the client that the job is done, clean up the objects
set jmail=nothing
%>

<%=strResult%>

SSJ
08-18-2008, 09:10 AM
Go through following loop and check which part is executed:
If NOT blnSpam Then
JMail.Execute
strResult = "Mail Sent."
Else
strResult = "Mail Not Sent." & Jmail.log
End If

Mostly it is Mail not Sent. Debug the blnSpam variable and try to get the value of it at each step