Print Page | Close Window

How to include sender's IP in a "contact us" form

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=20862
Printed Date: 30 March 2026 at 9:24am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: How to include sender's IP in a "contact us" form
Posted By: iSec
Subject: How to include sender's IP in a "contact us" form
Date Posted: 31 July 2006 at 8:46am

How do I include the IP address of the person that uses a "contact us" form ...

P.S. The form is ASP-based... created by webwiz guide..and uses JMail component.


-------------
"When it gets dark enough, you can see the stars"
-Charles A. Beard



Replies:
Posted By: Scotty32
Date Posted: 31 July 2006 at 9:10am
http://www.s2h.co.uk/asp/reference/request/servervariables.asp - visit this page.

all you do is:
Request.ServerVariables("REMOTE_ADDR")




-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: iSec
Date Posted: 31 July 2006 at 9:41am
I placed that line of code within the script and tried to sent a test message...but it didn't deliver the ip address within the email message.


-------------
"When it gets dark enough, you can see the stars"
-Charles A. Beard


Posted By: Bluefrog
Date Posted: 31 July 2006 at 11:42am
I've written some tutorials on this kind of stuff. Check out the one on http://renegademinds.com/Default.aspx?tabid=49 - HTTP headers . It has code samples. The samples there will give you all the headers available and you can just plug them in then.

But make sure that you add it to the email body properly.




-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music


Posted By: Scotty32
Date Posted: 01 August 2006 at 10:07am
i just tested the code i gave you, it works perfectly fine for me.

could you paste up the code for your script?


-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: Tegwin
Date Posted: 02 August 2006 at 11:44pm
I have a feedback form on my website using exactly this. It sends me the IP Address in an email form. I have pasted the code on here for you which I modified from some code I found on the internet.

First I declared the variable called strIP 

' Get the Users IP address
strIP = request.ServerVariables("REMOTE_ADDR")

 Then I use the JMAIL Component to send the email ... See the RED bit for where I display the IP Address in my email


Set JMail = Server.CreateObject("JMail.SMTPMail")


JMail.ServerAddress = "blah.blah.com" 'Change this line to the address of your email server.
JMail.AddRecipient "blah@blah.com" ' change this line to the email address to receive the mail at

JMail.Sender = t2   ' This populates the Sender of the email with the persons email address entered in the form
JMail.Subject = "Web Site Feedback"  'This can be changed to anything you want

JMail.HTMLBody = "<B>FROM : </B>" & t1 & "<BR>" & "<B>Email: </B>" & t2 & "<BR>" & "<B>Subject: </B>" & Subj &  "<BR>" & "<B>Tel: </B>" & Tel & "<BR>" & "<B>Comments: </B>" & st & "<BR>" & "<B>IPAddress: </B>" & strIP & "<BR>" & "<BR>" & "<HR>" & "<BR>" & "This email was sent on :" & Time1 & "&nbsp;&nbsp;" & Date1 ' This is the bit that actually formats the email so that it readable


JMail.Execute 'Execute the email
Set JMail = Nothing ' Reset the JMAIL to nothing

Hope this helps you.






Posted By: iSec
Date Posted: 03 August 2006 at 10:47pm
Hello all...
Sorry about the late reply... it was a busy week..
Bluefrog...I tried that but no luck,.... I know i;m doing something wrong but i don't know where...
 
Tegwin... the form I use is a little different than yours... I declared the variable and then included the code with the rest of other code and it still, didn't deliver the ip address yet...
 
Scotty...here is the code I use on my site... the part in red is from what Tegwin advised...
 

<%
'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
Response.Buffer = True
'Dimension variables
Dim strBody    'Holds the body of the e-mail
Dim objJMail    'Holds the mail server object
Dim strMyEmailAddress   'Holds your e-mail address
Dim strSMTPServerAddress 'Holds the SMTP Server address
Dim strCCEmailAddress  'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
Dim strBCCEmailAddress  'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user
Dim strIP = request.ServerVariables("REMOTE_ADDR") 'Get the Users IP address

'----------------- Place your e-mail address in the following sting ---------------------------------
strMyEmailAddress = "my email address"
'---------- Place the address of the SMTP server you are using in the following sting ---------------
strSMTPServerAddress = "server addresss..."
'-------------------- Place Carbon Copy e-mail address in the following sting ------------------------
strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail
'-------------------- Place Blind Copy e-mail address in the following sting -------------------------
strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail
'-----------------------------------------------------------------------------------------------------
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("email")
'Get the IP address of the sender
Request.ServerVariables("REMOTE_ADDR")
'Initialse strBody string with the body of the e-mail
strBody = "<h2>Website Inquiry</h2>"
strBody = strBody & "<br><b>Name: </b>" & Request.Form("firstName") & " " & Request.Form("lastName")
strBody = strBody & "<br><br><b>Address: -</b>"
If (Request.Form("street1")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("street1")
End If
If (Request.Form("street2")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("street2")
End If
If (Request.Form("town")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("town")
End If
If (Request.Form("county")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("county")
End If
If (Request.Form("country")) > "--- Choose One ---" Then
 strBody = strBody & "<br>  " & Request.Form("country")
End IF
If (Request.Form("postCode")) > "" Then
 strBody = strBody & "<br>  " & Request.Form("postCode")
End If
strBody = strBody & "<br><br><b>Telephone: </b>" & Request.Form("tel")
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
strBody = strBody & "<br><br><b>Enquiry: - </b><br>" & Replace(Request.Form("enquiry"), vbCrLf, "<br>")

'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then
 
 'Set the return e-mail address to your own
 strReturnEmailAddress = strMyEmailAddress
End If 

'Send the e-mail
'Create the e-mail server object
Set objJMail = Server.CreateObject("JMail.SMTPMail")
'Out going SMTP mail server address
objJMail.ServerAddress = strSMTPServerAddress
'Senders email address
objJMail.Sender = strReturnEmailAddress
'Senders name
objJMail.SenderName = Request.Form("firstName") & " " & Request.Form("lastName")
'Who the email is sent to
objJMail.AddRecipient strMyEmailAddress
'Who the carbon copies are sent to
objJMail.AddRecipientCC strCCEmailAddress
'Who the blind copies are sent to
objJMail.AddRecipientBCC strBCCEmailAddress
'Set the subject of the e-mail
objJMail.Subject = "Enquiry sent from enquiry form on website"

'Set the main body of the e-mail (HTML format)
objJMail.HTMLBody = strBody
'Set the main body of the e-mail (Plain Text format)
'objJMail.Body = strBody
'Importance of the e-mail ( 1 - highest priority, 3 - normal, 5 - lowest)
objJMail.Priority = 3
'Send the e-mail
objJMail.Execute
 
'Close the server object
Set objJMail = Nothing
%>


-------------
"When it gets dark enough, you can see the stars"
-Charles A. Beard


Posted By: Tegwin
Date Posted: 04 August 2006 at 12:15am
Scotty,
You have only declared the variable you have not displayed it.  strIP is the variable that holds the IP address, so you will need to have something like this.  You need to add the strIP to the StrBody somewhere .. like this


strBody = strBody & "<br><br><b>IP Address  - & strIP</b>"



Have a look at my code again, you will see this is what I have done.
Also you will need to remove the line

'Get the IP address of the sender
Request.ServerVariables("REMOTE_ADDR")





Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net