Solved

A walk-through of a form submission script - how-to and where to put it...

Posted on 2008-10-17
41
717 Views
Last Modified: 2013-12-25
Ok, so here'goes.  I'm an audio engineer & tech who fell ass-backwards into a web job.  I say that because I can pick up on things quickly, I do understand concepts just not procedure, but, most importantly, I'm learning as I go.

I'm trying to find a sort of stock script or something relatively cookie-cutter that will allow me to submit a form to an email address.  I have formmail.asp, and I thought I'd made all of the appropriate adjustments to the script, but apparently not.  I can't get the form to submit properly.  

The host has been very little help as to what sort of script they would support - they say that they're a "plug-in" site host and "stuff like that" is completely custom and us up to us, the users, to figure out.

Can someone walk me through the process of adjusting the script and tell me where to place the script on the server (i.e. which directory or subdirectory)?  

Thanks!
0
Comment
Question by:njschenck
  • 21
  • 19
41 Comments
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22742660
HI, its all depend on the IIS server directory/virtual directory where you can host your asp page, you also have to check the permission and wheter on server it can accept ASP pages for processing

could you please post the error message detail
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22742727
http://www.w3schools.com/asp/default.asp - good step by step tutorial
0
 
LVL 39

Expert Comment

by:Adam314
ID: 22742962
If ASP is not supported, but perl is, you can use the nms formmail.
    http://nms-cgi.sourceforge.net/scripts.shtml
It is very popular when using perl, and includes setup instructions.

You would normally place it in your cgi-bin directory, but this is host specific.
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22743196
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22743229
you can use CDO mail in ASP (Collaborative Data Object, which ships with NT Option Pack 4)
ASP Web Based Email Using Microsoft's CDONTS tutorial
http://www.webwizguide.com/kb/asp_tutorials/email_using_cdonts_tutorial.asp

http://www.4guysfromrolla.com/webtech/112298-1.shtml

Sending Email Via an External SMTP Server Using CDO
http://www.asp101.com/articles/john/cdosmtprelay/default.asp
0
 

Author Comment

by:njschenck
ID: 22743623
This is the error message when sending with formmail.asp:

Microsoft VBScript runtime error '800a0009'

Subscript out of range: '[number: 2]'

/allshows/chicago_entry/formmail.asp, line 96

Sorry for the delayed response - I was travelling between offices.  I'll be checking out those links now.

Thanks!
0
 

Author Comment

by:njschenck
ID: 22743768
Also, this is line 90 - 103, where line 96 begins with "if referer(2)"

Thought I should mention that given the error message.

Thank you!
verify the referer

'----------------------------------------------------------------------------------------------------

referer = request.ServerVariables("HTTP_REFERER") 

referer = split(referer,"/")

url_verified = "no"

for icounter = Lbound(url) to Ubound(url) '

	if referer(2) = url(icounter) then

		url_verified = "yes"

	end if

next

if not url_verified = "yes" then 

	response.write("The url specified is invalid!")

	response.End

end if

Open in new window

0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22744976
could you please try the below code
the referer

'----------------------------------------------------------------------------------------------------

var refererMain

refererMain = request.ServerVariables("HTTP_REFERER") 
 

referer = split(refererMain,"/")

url_verified = "no"

for icounter = Lbound(url) to Ubound(url) '

	if referer(2) = url(icounter) then

		url_verified = "yes"

	end if

next

if not url_verified = "yes" then 

	response.write("The url specified is invalid!")

	response.End

end if

Open in new window

0
 

Author Comment

by:njschenck
ID: 22744977
here's the error message from the script on "http://www.asp101.com/articles/john/cdosmtprelay/default.asp":

error '8004020f'
/allshows/chicago_entry/sendmsg.asp, line 42

and there was just a blank page from the script from "http://www.w3schools.com/asp/asp_send_email.asp"

of course, I modified these scripts with information I thought would have been useful.  where did I go wrong?

Line 42 of the failed script is attached.

Thanks for input... I think it's on the brink of actually working.  Anyone have the last hair of info?
.Send

Open in new window

0
 

Author Comment

by:njschenck
ID: 22745042
Thanks, but that didn't do it either.  New error:

Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'refererMain'

/allshows/chicago_entry/formmail.asp, line 92
0
 

Author Comment

by:njschenck
ID: 22745125
I decided I'd attach the entire piece of code for formmail.asp

Thought maybe it might be able to help along with the process (i.e. see if there's anything blatantly wrong that I don't know to look for)


'----------------------------------------------------------------------------------------------------

'declare variables

'----------------------------------------------------------------------------------------------------

Dim strFrom, strTo, strSubject, strBody

Dim objMessage, objConfig, strServer, intPort

Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2

Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok
 

'############################## CONFIGURATION VARIABLES ####################################
 

'These are the only lines you will need to change

'----------------------------------------------------------------------------------------------------

strServer = "smtp.tkt.com" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"

intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)

'Referrer's Array is defined here. Enter the valid domains which may use this script.

url = Array("www.tkt.com","tkt.com")'Set which urls that will be accepted. http://xxxxx/

	'Seperate multiple domains by commas 

	'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")

	'computer names can be used instead of domains if this script is being run locally

	'eg: url = Array("computername")
 

'######################################### IMPORTANT NOTICE #########################################

'IMPORTANT: do not modify anything below this line unless you know what you are doing!!

'######################################### IMPORTANT NOTICE #########################################

	

'----------------------------------------------------------------------------------------------------

'information type and CDOSYS constants

'----------------------------------------------------------------------------------------------------

%>

<!--METADATA TYPE="typelib"

UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"

NAME="CDO for Windows 2000 Library" -->

<!--METADATA TYPE="typelib"

UUID="00000205-0000-0010-8000-00AA006D2EA4"

NAME="ADODB Type Library" -->

<%

'----------------------------------------------------------------------------------------------------

'retrieved default fields

'----------------------------------------------------------------------------------------------------

recipient = request("recipient")

redirect = request("redirect")

subject = request("subject")

email = request("email")

required = request("required") 

if required = "" then

	required = "recipient,subject,email,redirect"

else

	required = "recipient,subject,email,redirect," & required

end if
 

'----------------------------------------------------------------------------------------------------

'verify the referer

'----------------------------------------------------------------------------------------------------

var refererMain

refererMain = request.ServerVariables("HTTP_REFERER") 

 

referer = split(refererMain,"/")

url_verified = "no"

for icounter = Lbound(url) to Ubound(url) '

        if referer(2) = url(icounter) then

                url_verified = "yes"

        end if

next

if not url_verified = "yes" then 

        response.write("The url specified is invalid!")

        response.End

end if
 

'----------------------------------------------------------------------------------------------------

'verify the recipient(not tested)

'----------------------------------------------------------------------------------------------------

'trimed_referer = split(referer(2),".")'

'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"

'if trimed_referer(0) = "www" then

'	if InStr(1,recipient,trimed_referer(1),1) = 0 then

'		response.write "recipient don't match the referer"

'		response.end

'	end if

'else

'	if InStr(1,recipient,trimed_referer(0),1) = 0 then

'		response.write "recipient don't match the referer"

'		response.end

'	end if

'end if
 

'----------------------------------------------------------------------------------------------------

'retrieve form contents and create email fields

'---------------------------------------------------------------------------------------------------- 

query = Request.ServerVariables("QUERY_STRING") 

query = split(query,"&")

query3 = split(required,",")

	For iLoop = Lbound(query) to UBound(query)

		query2 = split(query(iloop),"=")

	

'----------------------------------------------------------------------------------------------------

'form validation, checks required fields are not null

'----------------------------------------------------------------------------------------------------

		for i = LBound(query3) to UBound(query3)

			if query3(i) = query2(0) then

				if query2(1) = "" then

					response.write ("you must enter a valid ") & query2(0)

					response.end

				end if

			end if

			

			'if query2(0) = "agree" then

				'if query2(1) <> "on" or query2(1) = "" then

				'	response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")

				'response.end

				'end if

			'end if

			

'----------------------------------------------------------------------------------------------------

'form validation, checks a valid email address has been specified

'----------------------------------------------------------------------------------------------------			

			if query2(0) = "email" then

				trim(query2(0))

				if len(query2(1))<8 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				if instr(query2(1),"@")=0 and instr(query2(1),".")=0 then

					response.write query2(1)

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				strEmail1 = split(query2(1),"@")

				if len(strEmail1(1))<3 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				strEmail2 = split(strEmail1(1),".")

				if len(strEmail2(0))<3 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				if len(strEmail2(1))<2 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

			end if
 

'----------------------------------------------------------------------------------------------------

'form validation, checks terms and conditions checkbox has been ticked

'----------------------------------------------------------------------------------------------------

			

		Next

		if not query2(0) = "recipient" and not query2(0) = "redirect" and not query2(0) = "subject" and not query2(0) = "realname" and not query2(0) = "email" and not query2(0) = "required" and not query2(0) = "agree" then

			strBody = strBody & vbnewline & vbnewline & query2(0) &": " & query2(1) 

		end if

	Next

if email = "" then

	email = "formmail@" & referer(2)

end if

'----------------------------------------------------------------------------------------------------

'replaces any special characters parsed through the query string

'----------------------------------------------------------------------------------------------------

strbody = replace(strbody, "+"," ")

strbody = replace(strbody, "%26%238364%3B","¬")

strbody = replace(strbody, "%A1","¡")

strbody = replace(strbody, "%A3","£")

strbody = replace(strbody, "%A8","¨")

strbody = replace(strbody, "%AA","ª")

strbody = replace(strbody, "%AC","¬")

strbody = replace(strbody, "%B4","´")

strbody = replace(strbody, "%B7","·")

strbody = replace(strbody, "%BA","º")

strbody = replace(strbody, "%BF","¿")

strbody = replace(strbody, "%C7","Ç")

strbody = replace(strbody, "%E7","ç")

strbody = replace(strbody, "%0D%0A",vbnewline)

strbody = replace(strbody, "%21","!")

strbody = replace(strbody, "%23","#")

strbody = replace(strbody, "%24","$")

strbody = replace(strbody, "%25","%")

strbody = replace(strbody, "%26","&")

strbody = replace(strbody, "%27","'")

strbody = replace(strbody, "%28","(")

strbody = replace(strbody, "%29",")")

strbody = replace(strbody, "%2B","+")

strbody = replace(strbody, "%2C",",")

strbody = replace(strbody, "%2D","-")

strbody = replace(strbody, "%2E",".")

strbody = replace(strbody, "%2F","/")

strbody = replace(strbody, "%3A",":")

strbody = replace(strbody, "%3B",";")

strbody = replace(strbody, "%3C","<")

strbody = replace(strbody, "%3D","=")

strbody = replace(strbody, "%3E",">")

strbody = replace(strbody, "%3F","?")

strbody = replace(strbody, "%5B","[")

strbody = replace(strbody, "%5C","\")

strbody = replace(strbody, "%5D","]")

strbody = replace(strbody, "%5E","^")

strbody = replace(strbody, "%5F","_")

strbody = replace(strbody, "%60","`")

strbody = replace(strbody, "%7B","{")

strbody = replace(strbody, "%7C","|")

strbody = replace(strbody, "%7D","}")

strbody = replace(strbody, "%7E","~")
 

'----------------------------------------------------------------------------------------------------

'this creates the body of the mail message, the text in quotes can be modified accordingly 

'---------------------------------------------------------------------------------------------------

strBody = "Here is the results of your form submitted from" & referer(2)  & vbnewline & vbnewline & "Name: " & realname & vbnewline &  vbnewline & "Email: " & email & vbnewline & strBody & vbnewline &  vbnewline & "############# End Formmail Tranmission #############" 
 

'----------------------------------------------------------------------------------------------------

'checks if a smtp port has been specified, if not it uses the default port 25

'----------------------------------------------------------------------------------------------------

if intport <> 25 then

	intport = intport

else

	intport = 25

end if
 

'----------------------------------------------------------------------------------------------------

'send the mail message

'----------------------------------------------------------------------------------------------------	

set objMessage = CreateObject("CDO.Message")

objMessage.To = recipient

objMessage.From = email

objMessage.Subject = subject

objMessage.Sender = email

objMessage.Textbody = strBody
 

'----------------------------------------------------------------------------------------------------

'cdosys configuration setup

'----------------------------------------------------------------------------------------------------

set objConfig = CreateObject("CDO.Configuration")

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort

objConfig.Fields(cdoSMTPServer) = strServer

objConfig.Fields(cdoSMTPServerPort) = intPort

objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous

objConfig.Fields.Update

set objMessage.Configuration = objConfig
 

'----------------------------------------------------------------------------------------------------

'define error handling procedures

'----------------------------------------------------------------------------------------------------

On Error Resume Next

	objMessage.Send

If Err.Number = 0 then

	response.write("Formmail v1.3 processed all operations successfully!")

else

	response.write("Formmail v1.3 detected the following errors:")& "<br>"

	response.write("error no.: ")&err.number & "<br>"

	response.write("description: ")&err.description & "<br>"

	response.end

End If

On Error Goto 0

	

'----------------------------------------------------------------------------------------------------

'send them to the page specified

'----------------------------------------------------------------------------------------------------

Response.Redirect redirect

Open in new window

0
 

Author Comment

by:njschenck
ID: 22758816
So, the only issue I'm getting is the referer section of the code (line 92, specifically).

The attached lines are 89-105 just for reference points.

Please - anyone who can see the error in my way, please slap me in the head with it...
'----------------------------------------------------------------------------------------------------

'verify the referer

'----------------------------------------------------------------------------------------------------

var refererMain

refererMain = request.ServerVariables("HTTP://www.allshows.com/allshows/chicago_entry/formmail.asp") 

 

referer = split(refererMain,"/")

url_verified = "no"

for icounter = Lbound(url) to Ubound(url) '

        if referer(2) = url(icounter) then

                url_verified = "yes"

        end if

next

if not url_verified = "yes" then 

        response.write("The url specified is invalid!")

        response.End

end if

Open in new window

0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22758877
hi,

what you want to do with

refererMain = request.ServerVariables("HTTP://www.allshows.com/allshows/chicago_entry/formmail.asp")
 
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22758983
here's the error message from the script on "http://www.asp101.com/articles/john/cdosmtprelay/default.asp":

error '8004020f'
/allshows/chicago_entry/sendmsg.asp, line 42

and there was just a blank page from the script from "http://www.w3schools.com/asp/asp_send_email.asp"

of course, I modified these scripts with information I thought would have been useful.  where did I go wrong?

Line 42 of the failed script is attached.
.Send
***********************************************
few things -
try http://www.w3schools.com/asp/asp_send_email.asp code without modifying any thing - is it working?
check for the CDONT permission
try the below link which has good info
http://support.microsoft.com/kb/324649
0
 

Author Comment

by:njschenck
ID: 22758991
I'm not sure I understand that... are you asking what I want to do, or did you make a change that just isn't apparent to me?
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22759083
yes, what you want to do with that code

also could you please also try commenting below line code - what I can see is, its doing the validation only so for testing just comment the below code and proceed
*********************************
' var refererMain
' refererMain = request.ServerVariables("HTTP://www.allshows.com/allshows/chicago_entry/formmail.asp")
 
' referer = split(refererMain,"/")
' url_verified = "no"
' for icounter = Lbound(url) to Ubound(url) '
'         if referer(2) = url(icounter) then
'                 url_verified = "yes"
'         end if
' next
' if not url_verified = "yes" then
'         response.write("The url specified is invalid!")
'         response.End
' end if
****************************************************
0
 

Author Comment

by:njschenck
ID: 22759395
Really, I appreciate you going through this hassle with me.  I say that because of the bad news that neither has worked.  The  one from http://www.w3schools.com/asp/asp_send_email.asp  still pulls up a blank page.  And I adjusted the formmail.asp code and it worked a little further - now line 191 is bunk.  And I think I see it needs to say something else, but I don't know about the syntax or whether I need the server or an address...  I've attached lines 185 - 192.

Thanks again.
		Next

		if not query2(0) = "recipient" and not query2(0) = "redirect" and not query2(0) = "subject" and not query2(0) = "realname" and not query2(0) = "email" and not query2(0) = "required" and not query2(0) = "agree" then

			strBody = strBody & vbnewline & vbnewline & query2(0) &": " & query2(1) 

		end if

	Next

if email = "" then

	email = "formmail@" & referer(2)

end if

Open in new window

0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22759515
Hi, just hardcode all the value like email message, From, To, body and all other variable and check if it is working, if it works means you dont have any problem with the CODNT permission, then one by one uncomment then variable email message, From, To, body and see where it is failing.
0
 

Author Comment

by:njschenck
ID: 22760669
You forget: I have no idea what you're talking about.

Certain phrases like "uncomment" are foreign to me.  Does it mean leave it as is?  Blank? Remove the whole line?  I'm sorry - I'm on a pretty elementary level with this.

Also, can you give me an example of hardcoded values?  Just so I know what you're talking about as far as syntax.
0
 

Author Comment

by:njschenck
ID: 22760672
You forget: I have no idea what you're talking about... Sorry...

Certain phrases like "uncomment" are foreign to me.  Does it mean leave it as is?  Blank? Remove the whole line?  I'm sorry - I'm on a pretty elementary level with this.

Also, can you give me an example of hardcoded values?  Just so I know what you're talking about as far as syntax.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22761073
could it be possible for you to copy paste your latest page code
also give me some more detail like
from which email id you want to send mail
to which email id you want to send mail
0
 

Author Comment

by:njschenck
ID: 22761183
Sure.  Thanks.

I'd like to receive at sales@allshows.com (it may be coded to nick@allshows.com for testing purposes at the moment)

Send from is really irrelevant, so sales@allshows.com would be fine

Thank you again!

<%@ Language = vbscript%>

<%option explicit %>

<%server.scripttimeout = 600 %>

<%

'------------------------------------------- FORMMAIL V1.3 ------------------------------------------
 

'----------------------------------------------------------------------------------------------------

'copyright information

'----------------------------------------------------------------------------------------------------

'Copyright 2002: Sorted Sites http://www.sortedsites.com

'Authors Jonas Tornqvist, David Parkes and Karl Snares

'This script is Freeware, which means you are free to use and modify 

'the script for your own use.

'The only condition is this copyright header remain intact and you don't 

'try and sell this script for profit without first asking us. 

'And of course also ask Matt Wright who wrote the original perl version of Formmail.
 

'----------------------------------------------------------------------------------------------------

'license agreement - Important

'----------------------------------------------------------------------------------------------------

'By using this script you agree to indeminfy the developers - Sorted Sites of any loss

'or damages that may arise from its use or missue.

'This script is provided as is with all faults - no warranties and no guarantees.

'basically its free - use it at your own risk and cost.

'No warranties and no tech support - if you need help with this don't ask us!

'The documentation is provided as is with all the help we can offer.

'As we develop this script we shall post updates hopefully fix any bugs

'We are not obliged to release any future versions and we might not bother...

'By using this script you accept this license agreement!
 

'----------------------------------------------------------------------------------------------------

'documentation v1.3

'----------------------------------------------------------------------------------------------------
 

'####################################################################################################

'this is where the code starts for real

'####################################################################################################
 

'----------------------------------------------------------------------------------------------------

'declare variables

'----------------------------------------------------------------------------------------------------

Dim strFrom, strTo, strSubject, strBody

Dim objMessage, objConfig, strServer, intPort

Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2

Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok
 

'############################## CONFIGURATION VARIABLES ####################################
 

'These are the only lines you will need to change

'----------------------------------------------------------------------------------------------------

strServer = "smtp.tkt.com" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"

intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)

'Referrer's Array is defined here. Enter the valid domains which may use this script.

url = Array("www.tkt.com","tkt.com")'Set which urls that will be accepted. http://xxxxx/

	'Seperate multiple domains by commas 

	'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")

	'computer names can be used instead of domains if this script is being run locally

	'eg: url = Array("computername")
 

'######################################### IMPORTANT NOTICE #########################################

'IMPORTANT: do not modify anything below this line unless you know what you are doing!!

'######################################### IMPORTANT NOTICE #########################################

	

'----------------------------------------------------------------------------------------------------

'information type and CDOSYS constants

'----------------------------------------------------------------------------------------------------

%>

<!--METADATA TYPE="typelib"

UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"

NAME="CDO for Windows 2000 Library" -->

<!--METADATA TYPE="typelib"

UUID="00000205-0000-0010-8000-00AA006D2EA4"

NAME="ADODB Type Library" -->

<%

'----------------------------------------------------------------------------------------------------

'retrieved default fields

'----------------------------------------------------------------------------------------------------

recipient = request("recipient")

redirect = request("redirect")

subject = request("subject")

email = request("email")

required = request("required") 

if required = "" then

	required = "recipient,subject,email,redirect"

else

	required = "recipient,subject,email,redirect," & required

end if
 

'----------------------------------------------------------------------------------------------------

'verify the referer

'----------------------------------------------------------------------------------------------------

' var refererMain

' refererMain = request.ServerVariables("HTTP://www.allshows.com/allshows/chicago_entry/formmail.asp")

 

' referer = split(refererMain,"/")

' url_verified = "no"

' for icounter = Lbound(url) to Ubound(url) '

'         if referer(2) = url(icounter) then

'                 url_verified = "yes"

'         end if

' next

' if not url_verified = "yes" then

'         response.write("The url specified is invalid!")

'         response.End

' end if
 

'----------------------------------------------------------------------------------------------------

'verify the recipient(not tested)

'----------------------------------------------------------------------------------------------------

'trimed_referer = split(referer(2),".")'

'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"

'if trimed_referer(0) = "www" then

'	if InStr(1,recipient,trimed_referer(1),1) = 0 then

'		response.write "recipient don't match the referer"

'		response.end

'	end if

'else

'	if InStr(1,recipient,trimed_referer(0),1) = 0 then

'		response.write "recipient don't match the referer"

'		response.end

'	end if

'end if
 

'----------------------------------------------------------------------------------------------------

'retrieve form contents and create email fields

'---------------------------------------------------------------------------------------------------- 

query = Request.ServerVariables("QUERY_STRING") 

query = split(query,"&")

query3 = split(required,",")

	For iLoop = Lbound(query) to UBound(query)

		query2 = split(query(iloop),"=")

	

'----------------------------------------------------------------------------------------------------

'form validation, checks required fields are not null

'----------------------------------------------------------------------------------------------------

		for i = LBound(query3) to UBound(query3)

			if query3(i) = query2(0) then

				if query2(1) = "" then

					response.write ("you must enter a valid ") & query2(0)

					response.end

				end if

			end if

			

			'if query2(0) = "agree" then

				'if query2(1) <> "on" or query2(1) = "" then

				'	response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")

				'response.end

				'end if

			'end if

			

'----------------------------------------------------------------------------------------------------

'form validation, checks a valid email address has been specified

'----------------------------------------------------------------------------------------------------			

			if query2(0) = "email" then

				trim(query2(0))

				if len(query2(1))<8 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				if instr(query2(1),"@")=0 and instr(query2(1),".")=0 then

					response.write query2(1)

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				strEmail1 = split(query2(1),"@")

				if len(strEmail1(1))<3 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				strEmail2 = split(strEmail1(1),".")

				if len(strEmail2(0))<3 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				if len(strEmail2(1))<2 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

			end if
 

'----------------------------------------------------------------------------------------------------

'form validation, checks terms and conditions checkbox has been ticked

'----------------------------------------------------------------------------------------------------

			

		Next

		if not query2(0) = "recipient" and not query2(0) = "redirect" and not query2(0) = "subject" and not query2(0) = "realname" and not query2(0) = "email" and not query2(0) = "required" and not query2(0) = "agree" then

			strBody = strBody & vbnewline & vbnewline & query2(0) &": " & query2(1) 

		end if

	Next

if email = "" then

	email = "formmail@" & referer(2)

end if

'----------------------------------------------------------------------------------------------------

'replaces any special characters parsed through the query string

'----------------------------------------------------------------------------------------------------

strbody = replace(strbody, "+"," ")

strbody = replace(strbody, "%26%238364%3B","¬")

strbody = replace(strbody, "%A1","¡")

strbody = replace(strbody, "%A3","£")

strbody = replace(strbody, "%A8","¨")

strbody = replace(strbody, "%AA","ª")

strbody = replace(strbody, "%AC","¬")

strbody = replace(strbody, "%B4","´")

strbody = replace(strbody, "%B7","·")

strbody = replace(strbody, "%BA","º")

strbody = replace(strbody, "%BF","¿")

strbody = replace(strbody, "%C7","Ç")

strbody = replace(strbody, "%E7","ç")

strbody = replace(strbody, "%0D%0A",vbnewline)

strbody = replace(strbody, "%21","!")

strbody = replace(strbody, "%23","#")

strbody = replace(strbody, "%24","$")

strbody = replace(strbody, "%25","%")

strbody = replace(strbody, "%26","&")

strbody = replace(strbody, "%27","'")

strbody = replace(strbody, "%28","(")

strbody = replace(strbody, "%29",")")

strbody = replace(strbody, "%2B","+")

strbody = replace(strbody, "%2C",",")

strbody = replace(strbody, "%2D","-")

strbody = replace(strbody, "%2E",".")

strbody = replace(strbody, "%2F","/")

strbody = replace(strbody, "%3A",":")

strbody = replace(strbody, "%3B",";")

strbody = replace(strbody, "%3C","<")

strbody = replace(strbody, "%3D","=")

strbody = replace(strbody, "%3E",">")

strbody = replace(strbody, "%3F","?")

strbody = replace(strbody, "%5B","[")

strbody = replace(strbody, "%5C","\")

strbody = replace(strbody, "%5D","]")

strbody = replace(strbody, "%5E","^")

strbody = replace(strbody, "%5F","_")

strbody = replace(strbody, "%60","`")

strbody = replace(strbody, "%7B","{")

strbody = replace(strbody, "%7C","|")

strbody = replace(strbody, "%7D","}")

strbody = replace(strbody, "%7E","~")
 

'----------------------------------------------------------------------------------------------------

'this creates the body of the mail message, the text in quotes can be modified accordingly 

'---------------------------------------------------------------------------------------------------

strBody = "Here is the results of your form submitted from" & referer(2)  & vbnewline & vbnewline & "Name: " & realname & vbnewline &  vbnewline & "Email: " & email & vbnewline & strBody & vbnewline &  vbnewline & "############# End Formmail Tranmission #############" 
 

'----------------------------------------------------------------------------------------------------

'checks if a smtp port has been specified, if not it uses the default port 25

'----------------------------------------------------------------------------------------------------

if intport <> 25 then

	intport = intport

else

	intport = 25

end if
 

'----------------------------------------------------------------------------------------------------

'send the mail message

'----------------------------------------------------------------------------------------------------	

set objMessage = CreateObject("CDO.Message")

objMessage.To = recipient

objMessage.From = email

objMessage.Subject = subject

objMessage.Sender = email

objMessage.Textbody = strBody
 

'----------------------------------------------------------------------------------------------------

'cdosys configuration setup

'----------------------------------------------------------------------------------------------------

set objConfig = CreateObject("CDO.Configuration")

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort

objConfig.Fields(cdoSMTPServer) = strServer

objConfig.Fields(cdoSMTPServerPort) = intPort

objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous

objConfig.Fields.Update

set objMessage.Configuration = objConfig
 

'----------------------------------------------------------------------------------------------------

'define error handling procedures

'----------------------------------------------------------------------------------------------------

On Error Resume Next

	objMessage.Send

If Err.Number = 0 then

	response.write("Formmail v1.3 processed all operations successfully!")

else

	response.write("Formmail v1.3 detected the following errors:")& "<br>"

	response.write("error no.: ")&err.number & "<br>"

	response.write("description: ")&err.description & "<br>"

	response.end

End If

On Error Goto 0

	

'----------------------------------------------------------------------------------------------------

'send them to the page specified

'----------------------------------------------------------------------------------------------------

Response.Redirect redirect
 

'####################################################################################################

'This is where the code ends

'####################################################################################################

%>

<!-- That's All Folks -->

<!-- Happy Surfing -->

<!-- Credits -->

<!-- David Parkes - Project Planning -->

<!-- Jonas Tornqvist - Lead Programmer version 1-->

<!-- Karl Snares - Lead Programmer version 1.2 & 1.3

<!-- Matt Wright - Original Formmail CGI Developer -->

Open in new window

0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22761347
try the below code, if you face any problem, give me exact error message with lilne number and other detail
<%@ Language = vbscript%>

<%option explicit %>

<%server.scripttimeout = 600 %>

<%

'----------------------------------------------------------------------------------------------------

'declare variables

'----------------------------------------------------------------------------------------------------

Dim strFrom, strTo, strSubject, strBody

Dim objMessage, objConfig, strServer, intPort

Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2

Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok

 

'############################## CONFIGURATION VARIABLES ####################################

 

'These are the only lines you will need to change

'----------------------------------------------------------------------------------------------------

strServer = "smtp.tkt.com" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"

intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)

'Referrer's Array is defined here. Enter the valid domains which may use this script.

url = Array("www.tkt.com","tkt.com")'Set which urls that will be accepted. http://xxxxx/

	'Seperate multiple domains by commas 

	'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")

	'computer names can be used instead of domains if this script is being run locally

	'eg: url = Array("computername")

 

'######################################### IMPORTANT NOTICE #########################################

'IMPORTANT: do not modify anything below this line unless you know what you are doing!!

'######################################### IMPORTANT NOTICE #########################################

	

'----------------------------------------------------------------------------------------------------

'information type and CDOSYS constants

'----------------------------------------------------------------------------------------------------

%>

<!--METADATA TYPE="typelib"

UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"

NAME="CDO for Windows 2000 Library" -->

<!--METADATA TYPE="typelib"

UUID="00000205-0000-0010-8000-00AA006D2EA4"

NAME="ADODB Type Library" -->

<%

'----------------------------------------------------------------------------------------------------

'retrieved default fields

'----------------------------------------------------------------------------------------------------

recipient = "nick@allshows.com" 'request("recipient")

redirect = request("redirect")

subject = "TEST MAIL" 'request("subject")

email = "sales@allshows.com" 'request("email")

required = request("required") 

 

'----------------------------------------------------------------------------------------------------

'this creates the body of the mail message, the text in quotes can be modified accordingly 

'---------------------------------------------------------------------------------------------------

strBody = "Here is the results of your form submitted from TEST MAIL ############# End Formmail Tranmission #############" 

 

'----------------------------------------------------------------------------------------------------

'checks if a smtp port has been specified, if not it uses the default port 25

'----------------------------------------------------------------------------------------------------

if intport <> 25 then

	intport = intport

else

	intport = 25

end if

 

'----------------------------------------------------------------------------------------------------

'send the mail message

'----------------------------------------------------------------------------------------------------	

set objMessage = CreateObject("CDO.Message")

objMessage.To = recipient

objMessage.From = email

objMessage.Subject = subject

objMessage.Sender = email

objMessage.Textbody = strBody

 

'----------------------------------------------------------------------------------------------------

'cdosys configuration setup

'----------------------------------------------------------------------------------------------------

set objConfig = CreateObject("CDO.Configuration")

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort

objConfig.Fields(cdoSMTPServer) = strServer

objConfig.Fields(cdoSMTPServerPort) = intPort

objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous

objConfig.Fields.Update

set objMessage.Configuration = objConfig

 

'----------------------------------------------------------------------------------------------------

'define error handling procedures

'----------------------------------------------------------------------------------------------------

On Error Resume Next

	objMessage.Send

If Err.Number = 0 then

	response.write("Formmail v1.3 processed all operations successfully!")

else

	response.write("Formmail v1.3 detected the following errors:")& "<br>"

	response.write("error no.: ")&err.number & "<br>"

	response.write("description: ")&err.description & "<br>"

	response.end

End If

On Error Goto 0

	

'----------------------------------------------------------------------------------------------------

'send them to the page specified

'----------------------------------------------------------------------------------------------------

Response.Redirect redirect

 

'####################################################################################################

'This is where the code ends

'####################################################################################################

%>

<!-- That's All Folks -->

<!-- Happy Surfing -->

<!-- Credits -->

<!-- David Parkes - Project Planning -->

<!-- Jonas Tornqvist - Lead Programmer version 1-->

<!-- Karl Snares - Lead Programmer version 1.2 & 1.3

<!-- Matt Wright - Original Formmail CGI Developer -->

Open in new window

0
 

Author Comment

by:njschenck
ID: 22761676
Thanks.

The exact error:

Formmail v1.3 detected the following errors:
error no.: -2147220973
description: The transport failed to connect to the server.
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22761823
it means you are not able to connect to that mail server, its mail server configuration
*****************************************
www.sortedsites.com/downloads/formmail-readme.rtf
Troubleshooting
Problem or Error Message
Formmail.asp executes successfully and redirects the user to the correct page. Only no email is sent.

Or

Formmail v1.3 detected the following errors:
error no.: -2147220973

Solution
description: The transport failed to connect to the server
This generally occurs when the Specified SMTP Service is disabled, by default the script uses the SMTP Service running on the web server at port 25 this will normally be the IIS SMTP Service, if this fails contact your hosting provider to discover the IP Address and Port number of a working SMTP Service. You will then need to modify the strserver variable described below.

To save the call to your host its often worthwhile trying the SMTP Server of the recipients mail account, this can be found in Outlook (Express) by selecting Tools> Accounts Selecting the Mail account and clicking Properties and then looking at the server tab. EG: mail.yourdomain.com or smtp.yourdomain.com.

*****************************************

http://www.sitepoint.com/forums/showthread.php?t=274003
was change the above line of code from "smtp.yourdomain.com" to "mail.yourdomain.com" which you will find in the account section of your email client under smtp.
******************************************


0
 

Author Comment

by:njschenck
ID: 22761907
Whoa! Getting closer!

I switched a couple things within the script and suddenly, I received the email.  It didn't contain any information from my form, and the subject was "TEST MAIL" despite the hidden fields in my form which should have set the subject.  The redirect didn't work either, but I think that's my fault -

What should I modify in order to get the info within the form to come across?

Thank you!!
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22761978
so what is the tweak you did, same tweak you have to apply to your original page and it has to work

All the best
0
 

Author Comment

by:njschenck
ID: 22762152
Some of the server information was incorrect, so I modified it.  Now there's an email going through, but the email doesn't include any of the form data.  I got the subject to show by changing the code from: "subject = "TEST MAIL" 'request("subject")" to "subject = request("subject")"

All I get in the email is: Here is the results of your form submitted from TEST MAIL ############# End Formmail Tranmission #############

That's verbatim.

I don't know what to call the pieces I need; that is, do I say "name = request("name")" if the textbox is called "name" or is there another method to it?  I'm trying to learn the syntax, I guess, so I can apply it to different aspects of the form.

Thank you again!
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22762188
could you please tell me what is the change you did to my code and then it started working, or just apply the same change to the below code
<%@ Language = vbscript%>

<%option explicit %>

<%server.scripttimeout = 600 %>

<%

'------------------------------------------- FORMMAIL V1.3 ------------------------------------------

 

'----------------------------------------------------------------------------------------------------

'copyright information

'----------------------------------------------------------------------------------------------------

'Copyright 2002: Sorted Sites http://www.sortedsites.com

'Authors Jonas Tornqvist, David Parkes and Karl Snares

'This script is Freeware, which means you are free to use and modify 

'the script for your own use.

'The only condition is this copyright header remain intact and you don't 

'try and sell this script for profit without first asking us. 

'And of course also ask Matt Wright who wrote the original perl version of Formmail.

 

'----------------------------------------------------------------------------------------------------

'license agreement - Important

'----------------------------------------------------------------------------------------------------

'By using this script you agree to indeminfy the developers - Sorted Sites of any loss

'or damages that may arise from its use or missue.

'This script is provided as is with all faults - no warranties and no guarantees.

'basically its free - use it at your own risk and cost.

'No warranties and no tech support - if you need help with this don't ask us!

'The documentation is provided as is with all the help we can offer.

'As we develop this script we shall post updates hopefully fix any bugs

'We are not obliged to release any future versions and we might not bother...

'By using this script you accept this license agreement!

 

'----------------------------------------------------------------------------------------------------

'documentation v1.3

'----------------------------------------------------------------------------------------------------

 

'####################################################################################################

'this is where the code starts for real

'####################################################################################################

 

'----------------------------------------------------------------------------------------------------

'declare variables

'----------------------------------------------------------------------------------------------------

Dim strFrom, strTo, strSubject, strBody

Dim objMessage, objConfig, strServer, intPort

Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2

Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok

 

'############################## CONFIGURATION VARIABLES ####################################

 

'These are the only lines you will need to change

'----------------------------------------------------------------------------------------------------

strServer = "smtp.tkt.com" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"

intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)

'Referrer's Array is defined here. Enter the valid domains which may use this script.

url = Array("www.tkt.com","tkt.com")'Set which urls that will be accepted. http://xxxxx/

	'Seperate multiple domains by commas 

	'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")

	'computer names can be used instead of domains if this script is being run locally

	'eg: url = Array("computername")

 

'######################################### IMPORTANT NOTICE #########################################

'IMPORTANT: do not modify anything below this line unless you know what you are doing!!

'######################################### IMPORTANT NOTICE #########################################

	

'----------------------------------------------------------------------------------------------------

'information type and CDOSYS constants

'----------------------------------------------------------------------------------------------------

%>

<!--METADATA TYPE="typelib"

UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"

NAME="CDO for Windows 2000 Library" -->

<!--METADATA TYPE="typelib"

UUID="00000205-0000-0010-8000-00AA006D2EA4"

NAME="ADODB Type Library" -->

<%

'----------------------------------------------------------------------------------------------------

'retrieved default fields

'----------------------------------------------------------------------------------------------------

recipient = request("recipient")

redirect = request("redirect")

subject = request("subject")

email = request("email")

required = request("required") 

if required = "" then

	required = "recipient,subject,email,redirect"

else

	required = "recipient,subject,email,redirect," & required

end if

 

'----------------------------------------------------------------------------------------------------

'verify the referer

'----------------------------------------------------------------------------------------------------

' var refererMain

' refererMain = request.ServerVariables("HTTP://www.allshows.com/allshows/chicago_entry/formmail.asp")

 

' referer = split(refererMain,"/")

' url_verified = "no"

' for icounter = Lbound(url) to Ubound(url) '

'         if referer(2) = url(icounter) then

'                 url_verified = "yes"

'         end if

' next

' if not url_verified = "yes" then

'         response.write("The url specified is invalid!")

'         response.End

' end if

 

'----------------------------------------------------------------------------------------------------

'verify the recipient(not tested)

'----------------------------------------------------------------------------------------------------

'trimed_referer = split(referer(2),".")'

'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"

'if trimed_referer(0) = "www" then

'	if InStr(1,recipient,trimed_referer(1),1) = 0 then

'		response.write "recipient don't match the referer"

'		response.end

'	end if

'else

'	if InStr(1,recipient,trimed_referer(0),1) = 0 then

'		response.write "recipient don't match the referer"

'		response.end

'	end if

'end if

 

'----------------------------------------------------------------------------------------------------

'retrieve form contents and create email fields

'---------------------------------------------------------------------------------------------------- 

query = Request.ServerVariables("QUERY_STRING") 

query = split(query,"&")

query3 = split(required,",")

	For iLoop = Lbound(query) to UBound(query)

		query2 = split(query(iloop),"=")

	

'----------------------------------------------------------------------------------------------------

'form validation, checks required fields are not null

'----------------------------------------------------------------------------------------------------

		for i = LBound(query3) to UBound(query3)

			if query3(i) = query2(0) then

				if query2(1) = "" then

					response.write ("you must enter a valid ") & query2(0)

					response.end

				end if

			end if

			

			'if query2(0) = "agree" then

				'if query2(1) <> "on" or query2(1) = "" then

				'	response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")

				'response.end

				'end if

			'end if

			

'----------------------------------------------------------------------------------------------------

'form validation, checks a valid email address has been specified

'----------------------------------------------------------------------------------------------------			

			if query2(0) = "email" then

				trim(query2(0))

				if len(query2(1))<8 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				if instr(query2(1),"@")=0 and instr(query2(1),".")=0 then

					response.write query2(1)

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				strEmail1 = split(query2(1),"@")

				if len(strEmail1(1))<3 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				strEmail2 = split(strEmail1(1),".")

				if len(strEmail2(0))<3 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				if len(strEmail2(1))<2 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

			end if

 

'----------------------------------------------------------------------------------------------------

'form validation, checks terms and conditions checkbox has been ticked

'----------------------------------------------------------------------------------------------------

			

		Next

		if not query2(0) = "recipient" and not query2(0) = "redirect" and not query2(0) = "subject" and not query2(0) = "realname" and not query2(0) = "email" and not query2(0) = "required" and not query2(0) = "agree" then

			strBody = strBody & vbnewline & vbnewline & query2(0) &": " & query2(1) 

		end if

	Next

if email = "" then

	email = "formmail@" & referer(2)

end if

'----------------------------------------------------------------------------------------------------

'replaces any special characters parsed through the query string

'----------------------------------------------------------------------------------------------------

strbody = replace(strbody, "+"," ")

strbody = replace(strbody, "%26%238364%3B","¬")

strbody = replace(strbody, "%A1","¡")

strbody = replace(strbody, "%A3","£")

strbody = replace(strbody, "%A8","¨")

strbody = replace(strbody, "%AA","ª")

strbody = replace(strbody, "%AC","¬")

strbody = replace(strbody, "%B4","´")

strbody = replace(strbody, "%B7","·")

strbody = replace(strbody, "%BA","º")

strbody = replace(strbody, "%BF","¿")

strbody = replace(strbody, "%C7","Ç")

strbody = replace(strbody, "%E7","ç")

strbody = replace(strbody, "%0D%0A",vbnewline)

strbody = replace(strbody, "%21","!")

strbody = replace(strbody, "%23","#")

strbody = replace(strbody, "%24","$")

strbody = replace(strbody, "%25","%")

strbody = replace(strbody, "%26","&")

strbody = replace(strbody, "%27","'")

strbody = replace(strbody, "%28","(")

strbody = replace(strbody, "%29",")")

strbody = replace(strbody, "%2B","+")

strbody = replace(strbody, "%2C",",")

strbody = replace(strbody, "%2D","-")

strbody = replace(strbody, "%2E",".")

strbody = replace(strbody, "%2F","/")

strbody = replace(strbody, "%3A",":")

strbody = replace(strbody, "%3B",";")

strbody = replace(strbody, "%3C","<")

strbody = replace(strbody, "%3D","=")

strbody = replace(strbody, "%3E",">")

strbody = replace(strbody, "%3F","?")

strbody = replace(strbody, "%5B","[")

strbody = replace(strbody, "%5C","\")

strbody = replace(strbody, "%5D","]")

strbody = replace(strbody, "%5E","^")

strbody = replace(strbody, "%5F","_")

strbody = replace(strbody, "%60","`")

strbody = replace(strbody, "%7B","{")

strbody = replace(strbody, "%7C","|")

strbody = replace(strbody, "%7D","}")

strbody = replace(strbody, "%7E","~")

 

'----------------------------------------------------------------------------------------------------

'this creates the body of the mail message, the text in quotes can be modified accordingly 

'---------------------------------------------------------------------------------------------------

strBody = "Here is the results of your form submitted from" & referer(2)  & vbnewline & vbnewline & "Name: " & realname & vbnewline &  vbnewline & "Email: " & email & vbnewline & strBody & vbnewline &  vbnewline & "############# End Formmail Tranmission #############" 

 

'----------------------------------------------------------------------------------------------------

'checks if a smtp port has been specified, if not it uses the default port 25

'----------------------------------------------------------------------------------------------------

if intport <> 25 then

	intport = intport

else

	intport = 25

end if

 

'----------------------------------------------------------------------------------------------------

'send the mail message

'----------------------------------------------------------------------------------------------------	

set objMessage = CreateObject("CDO.Message")

objMessage.To = recipient

objMessage.From = email

objMessage.Subject = subject

objMessage.Sender = email

objMessage.Textbody = strBody

 

'----------------------------------------------------------------------------------------------------

'cdosys configuration setup

'----------------------------------------------------------------------------------------------------

set objConfig = CreateObject("CDO.Configuration")

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort

objConfig.Fields(cdoSMTPServer) = strServer

objConfig.Fields(cdoSMTPServerPort) = intPort

objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous

objConfig.Fields.Update

set objMessage.Configuration = objConfig

 

'----------------------------------------------------------------------------------------------------

'define error handling procedures

'----------------------------------------------------------------------------------------------------

On Error Resume Next

	objMessage.Send

If Err.Number = 0 then

	response.write("Formmail v1.3 processed all operations successfully!")

else

	response.write("Formmail v1.3 detected the following errors:")& "<br>"

	response.write("error no.: ")&err.number & "<br>"

	response.write("description: ")&err.description & "<br>"

	response.end

End If

On Error Goto 0

	

'----------------------------------------------------------------------------------------------------

'send them to the page specified

'----------------------------------------------------------------------------------------------------

Response.Redirect redirect

 

'####################################################################################################

'This is where the code ends

'####################################################################################################

%>

<!-- That's All Folks -->

<!-- Happy Surfing -->

<!-- Credits -->

<!-- David Parkes - Project Planning -->

<!-- Jonas Tornqvist - Lead Programmer version 1-->

<!-- Karl Snares - Lead Programmer version 1.2 & 1.3

<!-- Matt Wright - Original Formmail CGI Developer -->

Open in new window

0
 

Author Comment

by:njschenck
ID: 22762220
Lines 17, 20, and 47
<%@ Language = vbscript%>

<%option explicit %>

<%server.scripttimeout = 600 %>

<%

'----------------------------------------------------------------------------------------------------

'declare variables

'----------------------------------------------------------------------------------------------------

Dim strFrom, strTo, strSubject, strBody

Dim objMessage, objConfig, strServer, intPort

Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2

Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok

 

'############################## CONFIGURATION VARIABLES ####################################

 

'These are the only lines you will need to change

'----------------------------------------------------------------------------------------------------

strServer = "mail.allshows.com" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"

intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)

'Referrer's Array is defined here. Enter the valid domains which may use this script.

url = Array("www.allshows.com","allshows.com")'Set which urls that will be accepted. http://xxxxx/

	'Seperate multiple domains by commas 

	'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")

	'computer names can be used instead of domains if this script is being run locally

	'eg: url = Array("computername")

 

'######################################### IMPORTANT NOTICE #########################################

'IMPORTANT: do not modify anything below this line unless you know what you are doing!!

'######################################### IMPORTANT NOTICE #########################################

	

'----------------------------------------------------------------------------------------------------

'information type and CDOSYS constants

'----------------------------------------------------------------------------------------------------

%>

<!--METADATA TYPE="typelib"

UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"

NAME="CDO for Windows 2000 Library" -->

<!--METADATA TYPE="typelib"

UUID="00000205-0000-0010-8000-00AA006D2EA4"

NAME="ADODB Type Library" -->

<%

'----------------------------------------------------------------------------------------------------

'retrieved default fields

'----------------------------------------------------------------------------------------------------

recipient = "nick@allshows.com" 'request("recipient")

redirect = request("redirect")

subject = request("subject")

email = "sales@allshows.com" 'request("email")

required = request("required") 

 

'----------------------------------------------------------------------------------------------------

'this creates the body of the mail message, the text in quotes can be modified accordingly 

'---------------------------------------------------------------------------------------------------

strBody = "Here is the results of your form submitted from TEST MAIL ############# End Formmail Tranmission #############" 

 

'----------------------------------------------------------------------------------------------------

'checks if a smtp port has been specified, if not it uses the default port 25

'----------------------------------------------------------------------------------------------------

if intport <> 25 then

	intport = intport

else

	intport = 25

end if

 

'----------------------------------------------------------------------------------------------------

'send the mail message

'----------------------------------------------------------------------------------------------------	

set objMessage = CreateObject("CDO.Message")

objMessage.To = recipient

objMessage.From = email

objMessage.Subject = subject

objMessage.Sender = email

objMessage.Textbody = strBody

 

'----------------------------------------------------------------------------------------------------

'cdosys configuration setup

'----------------------------------------------------------------------------------------------------

set objConfig = CreateObject("CDO.Configuration")

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort

objConfig.Fields(cdoSMTPServer) = strServer

objConfig.Fields(cdoSMTPServerPort) = intPort

objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous

objConfig.Fields.Update

set objMessage.Configuration = objConfig

 

'----------------------------------------------------------------------------------------------------

'define error handling procedures

'----------------------------------------------------------------------------------------------------

On Error Resume Next

	objMessage.Send

If Err.Number = 0 then

	response.write("Formmail v1.3 processed all operations successfully!")

else

	response.write("Formmail v1.3 detected the following errors:")& "<br>"

	response.write("error no.: ")&err.number & "<br>"

	response.write("description: ")&err.description & "<br>"

	response.end

End If

On Error Goto 0

	

'----------------------------------------------------------------------------------------------------

'send them to the page specified

'----------------------------------------------------------------------------------------------------

Response.Redirect redirect

 

'####################################################################################################

'This is where the code ends

'####################################################################################################

%>

<!-- That's All Folks -->

<!-- Happy Surfing -->

<!-- Credits -->

<!-- David Parkes - Project Planning -->

<!-- Jonas Tornqvist - Lead Programmer version 1-->

<!-- Karl Snares - Lead Programmer version 1.2 & 1.3

<!-- Matt Wright - Original Formmail CGI Developer -->

Open in new window

0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22762289
now do the same changes to the below code
line 51, 54 and if required to line 81
<%@ Language = vbscript%>

<%option explicit %>

<%server.scripttimeout = 600 %>

<%

'------------------------------------------- FORMMAIL V1.3 ------------------------------------------

 

'----------------------------------------------------------------------------------------------------

'copyright information

'----------------------------------------------------------------------------------------------------

'Copyright 2002: Sorted Sites http://www.sortedsites.com

'Authors Jonas Tornqvist, David Parkes and Karl Snares

'This script is Freeware, which means you are free to use and modify 

'the script for your own use.

'The only condition is this copyright header remain intact and you don't 

'try and sell this script for profit without first asking us. 

'And of course also ask Matt Wright who wrote the original perl version of Formmail.

 

'----------------------------------------------------------------------------------------------------

'license agreement - Important

'----------------------------------------------------------------------------------------------------

'By using this script you agree to indeminfy the developers - Sorted Sites of any loss

'or damages that may arise from its use or missue.

'This script is provided as is with all faults - no warranties and no guarantees.

'basically its free - use it at your own risk and cost.

'No warranties and no tech support - if you need help with this don't ask us!

'The documentation is provided as is with all the help we can offer.

'As we develop this script we shall post updates hopefully fix any bugs

'We are not obliged to release any future versions and we might not bother...

'By using this script you accept this license agreement!

 

'----------------------------------------------------------------------------------------------------

'documentation v1.3

'----------------------------------------------------------------------------------------------------

 

'####################################################################################################

'this is where the code starts for real

'####################################################################################################

 

'----------------------------------------------------------------------------------------------------

'declare variables

'----------------------------------------------------------------------------------------------------

Dim strFrom, strTo, strSubject, strBody

Dim objMessage, objConfig, strServer, intPort

Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2

Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok

 

'############################## CONFIGURATION VARIABLES ####################################

 

'These are the only lines you will need to change

'----------------------------------------------------------------------------------------------------

strServer = "smtp.tkt.com" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"

intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)

'Referrer's Array is defined here. Enter the valid domains which may use this script.

url = Array("www.tkt.com","tkt.com")'Set which urls that will be accepted. http://xxxxx/

	'Seperate multiple domains by commas 

	'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")

	'computer names can be used instead of domains if this script is being run locally

	'eg: url = Array("computername")

 

'######################################### IMPORTANT NOTICE #########################################

'IMPORTANT: do not modify anything below this line unless you know what you are doing!!

'######################################### IMPORTANT NOTICE #########################################

	

'----------------------------------------------------------------------------------------------------

'information type and CDOSYS constants

'----------------------------------------------------------------------------------------------------

%>

<!--METADATA TYPE="typelib"

UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"

NAME="CDO for Windows 2000 Library" -->

<!--METADATA TYPE="typelib"

UUID="00000205-0000-0010-8000-00AA006D2EA4"

NAME="ADODB Type Library" -->

<%

'----------------------------------------------------------------------------------------------------

'retrieved default fields

'----------------------------------------------------------------------------------------------------

recipient = request("recipient")

redirect = request("redirect")

subject = request("subject")

email = request("email")

required = request("required") 

if required = "" then

	required = "recipient,subject,email,redirect"

else

	required = "recipient,subject,email,redirect," & required

end if

 

'----------------------------------------------------------------------------------------------------

'verify the referer

'----------------------------------------------------------------------------------------------------

' var refererMain

' refererMain = request.ServerVariables("HTTP://www.allshows.com/allshows/chicago_entry/formmail.asp")

 

' referer = split(refererMain,"/")

' url_verified = "no"

' for icounter = Lbound(url) to Ubound(url) '

'         if referer(2) = url(icounter) then

'                 url_verified = "yes"

'         end if

' next

' if not url_verified = "yes" then

'         response.write("The url specified is invalid!")

'         response.End

' end if

 

'----------------------------------------------------------------------------------------------------

'verify the recipient(not tested)

'----------------------------------------------------------------------------------------------------

'trimed_referer = split(referer(2),".")'

'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"

'if trimed_referer(0) = "www" then

'	if InStr(1,recipient,trimed_referer(1),1) = 0 then

'		response.write "recipient don't match the referer"

'		response.end

'	end if

'else

'	if InStr(1,recipient,trimed_referer(0),1) = 0 then

'		response.write "recipient don't match the referer"

'		response.end

'	end if

'end if

 

'----------------------------------------------------------------------------------------------------

'retrieve form contents and create email fields

'---------------------------------------------------------------------------------------------------- 

query = Request.ServerVariables("QUERY_STRING") 

query = split(query,"&")

query3 = split(required,",")

	For iLoop = Lbound(query) to UBound(query)

		query2 = split(query(iloop),"=")

	

'----------------------------------------------------------------------------------------------------

'form validation, checks required fields are not null

'----------------------------------------------------------------------------------------------------

		for i = LBound(query3) to UBound(query3)

			if query3(i) = query2(0) then

				if query2(1) = "" then

					response.write ("you must enter a valid ") & query2(0)

					response.end

				end if

			end if

			

			'if query2(0) = "agree" then

				'if query2(1) <> "on" or query2(1) = "" then

				'	response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")

				'response.end

				'end if

			'end if

			

'----------------------------------------------------------------------------------------------------

'form validation, checks a valid email address has been specified

'----------------------------------------------------------------------------------------------------			

			if query2(0) = "email" then

				trim(query2(0))

				if len(query2(1))<8 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				if instr(query2(1),"@")=0 and instr(query2(1),".")=0 then

					response.write query2(1)

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				strEmail1 = split(query2(1),"@")

				if len(strEmail1(1))<3 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				strEmail2 = split(strEmail1(1),".")

				if len(strEmail2(0))<3 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

				if len(strEmail2(1))<2 then

					response.Write("You must specify a valid ") & query2(0)

					response.end

				end if

			end if

 

'----------------------------------------------------------------------------------------------------

'form validation, checks terms and conditions checkbox has been ticked

'----------------------------------------------------------------------------------------------------

			

		Next

		if not query2(0) = "recipient" and not query2(0) = "redirect" and not query2(0) = "subject" and not query2(0) = "realname" and not query2(0) = "email" and not query2(0) = "required" and not query2(0) = "agree" then

			strBody = strBody & vbnewline & vbnewline & query2(0) &": " & query2(1) 

		end if

	Next

if email = "" then

	email = "formmail@" & referer(2)

end if

'----------------------------------------------------------------------------------------------------

'replaces any special characters parsed through the query string

'----------------------------------------------------------------------------------------------------

strbody = replace(strbody, "+"," ")

strbody = replace(strbody, "%26%238364%3B","¬")

strbody = replace(strbody, "%A1","¡")

strbody = replace(strbody, "%A3","£")

strbody = replace(strbody, "%A8","¨")

strbody = replace(strbody, "%AA","ª")

strbody = replace(strbody, "%AC","¬")

strbody = replace(strbody, "%B4","´")

strbody = replace(strbody, "%B7","·")

strbody = replace(strbody, "%BA","º")

strbody = replace(strbody, "%BF","¿")

strbody = replace(strbody, "%C7","Ç")

strbody = replace(strbody, "%E7","ç")

strbody = replace(strbody, "%0D%0A",vbnewline)

strbody = replace(strbody, "%21","!")

strbody = replace(strbody, "%23","#")

strbody = replace(strbody, "%24","$")

strbody = replace(strbody, "%25","%")

strbody = replace(strbody, "%26","&")

strbody = replace(strbody, "%27","'")

strbody = replace(strbody, "%28","(")

strbody = replace(strbody, "%29",")")

strbody = replace(strbody, "%2B","+")

strbody = replace(strbody, "%2C",",")

strbody = replace(strbody, "%2D","-")

strbody = replace(strbody, "%2E",".")

strbody = replace(strbody, "%2F","/")

strbody = replace(strbody, "%3A",":")

strbody = replace(strbody, "%3B",";")

strbody = replace(strbody, "%3C","<")

strbody = replace(strbody, "%3D","=")

strbody = replace(strbody, "%3E",">")

strbody = replace(strbody, "%3F","?")

strbody = replace(strbody, "%5B","[")

strbody = replace(strbody, "%5C","\")

strbody = replace(strbody, "%5D","]")

strbody = replace(strbody, "%5E","^")

strbody = replace(strbody, "%5F","_")

strbody = replace(strbody, "%60","`")

strbody = replace(strbody, "%7B","{")

strbody = replace(strbody, "%7C","|")

strbody = replace(strbody, "%7D","}")

strbody = replace(strbody, "%7E","~")

 

'----------------------------------------------------------------------------------------------------

'this creates the body of the mail message, the text in quotes can be modified accordingly 

'---------------------------------------------------------------------------------------------------

strBody = "Here is the results of your form submitted from" & referer(2)  & vbnewline & vbnewline & "Name: " & realname & vbnewline &  vbnewline & "Email: " & email & vbnewline & strBody & vbnewline &  vbnewline & "############# End Formmail Tranmission #############" 

 

'----------------------------------------------------------------------------------------------------

'checks if a smtp port has been specified, if not it uses the default port 25

'----------------------------------------------------------------------------------------------------

if intport <> 25 then

	intport = intport

else

	intport = 25

end if

 

'----------------------------------------------------------------------------------------------------

'send the mail message

'----------------------------------------------------------------------------------------------------	

set objMessage = CreateObject("CDO.Message")

objMessage.To = recipient

objMessage.From = email

objMessage.Subject = subject

objMessage.Sender = email

objMessage.Textbody = strBody

 

'----------------------------------------------------------------------------------------------------

'cdosys configuration setup

'----------------------------------------------------------------------------------------------------

set objConfig = CreateObject("CDO.Configuration")

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort

objConfig.Fields(cdoSMTPServer) = strServer

objConfig.Fields(cdoSMTPServerPort) = intPort

objConfig.Fields(cdoSMTPAuthenticate) = cdoAnonymous

objConfig.Fields.Update

set objMessage.Configuration = objConfig

 

'----------------------------------------------------------------------------------------------------

'define error handling procedures

'----------------------------------------------------------------------------------------------------

On Error Resume Next

	objMessage.Send

If Err.Number = 0 then

	response.write("Formmail v1.3 processed all operations successfully!")

else

	response.write("Formmail v1.3 detected the following errors:")& "<br>"

	response.write("error no.: ")&err.number & "<br>"

	response.write("description: ")&err.description & "<br>"

	response.end

End If

On Error Goto 0

	

'----------------------------------------------------------------------------------------------------

'send them to the page specified

'----------------------------------------------------------------------------------------------------

Response.Redirect redirect

 

'####################################################################################################

'This is where the code ends

'####################################################################################################

%>

<!-- That's All Folks -->

<!-- Happy Surfing -->

<!-- Credits -->

<!-- David Parkes - Project Planning -->

<!-- Jonas Tornqvist - Lead Programmer version 1-->

<!-- Karl Snares - Lead Programmer version 1.2 & 1.3

<!-- Matt Wright - Original Formmail CGI Developer -->

Open in new window

0
 

Author Comment

by:njschenck
ID: 22762387
I copied in your code there, modified the points you mentioned and it failed.  Error message:

Microsoft VBScript runtime error '800a000d'

Type mismatch

/allshows/chicago_entry/formmail3.asp, line 191

191 is the referer, and appears to be exactly the same as the last script, which, despite missing information, was sending an email.  

Did I screw this one, too?
0
 

Author Comment

by:njschenck
ID: 22762430
I lied - I meant looks like the one from the original - which explains why that failed (that was one of the errors I was getting earlier as well)
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22762506
so in that code at line 191
just change
----------------------------------------------------------------------------------------------------
if email = "" then
      email = "formmail@" & referer(2)
end if
----------------------------------------------------------------------------------------------------
to
----------------------------------------------------------------------------------------------------
if email = "" then
      email = "nick@allshows.com" ' & referer(2)
end if
----------------------------------------------------------------------------------------------------
0
 

Author Comment

by:njschenck
ID: 22762556
I swear you're awesome.  I tried that a few minutes ago and it didn't work - I got the same error, but now line 243 is bunk.  So, we're moving forward.  Slowly, and most likely very painfully for you, but forward nevertheless.

error:

Microsoft VBScript runtime error '800a000d'

Type mismatch

/allshows/chicago_entry/formmail3.asp, line 243
0
 
LVL 7

Accepted Solution

by:
ASPSQLServerCOM earned 375 total points
ID: 22762669
at line 243 replace referer(2) by nick@allshows.com so it has to read like

strBody = "Here is the results of your form submitted from nick@allshows.com" & vbnewline & vbnewline & "Name: " & realname & vbnewline &  vbnewline & "Email: " & email & vbnewline & strBody & vbnewline &  vbnewline & "############# End Formmail Tranmission #############"
0
 

Author Comment

by:njschenck
ID: 22767419
You Rock.  How do I "close the question"?  I clicked accept solution, but it said something about closing the question and I'd like to make sure you're awarded the proper points.

Thank you!
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22767672
**** but it said something about closing the question
what is the message it gave you
0
 

Author Comment

by:njschenck
ID: 22767752
"If you have any general comments about the solution, please close the question first, then post the comment."
I thought I was closing the question by "accepting as solution" but, I've never done this before and was afraid of screwing it up.
0
 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22767839
How do I close a question?
There are five ways:

Accept an Expert's comment as the solution
If an Expert has given you the solution to your question, or has led you to the solution, select this option.

Accept multiple solutions
If several Experts collaborated to provide a solution, use this option and split the points among them.

Accept your own comment as the solution
If you solved your problem with no assistance from any Expert, post your solution and then click the Accept As Solution button in your own comment.

Accept your own comment, and award points to Experts for their assistance
If you answered your own question, but wish to award points to Experts for their attempts to help, use this option.

Delete your question
If you are not getting the kinds of responses that will lead to a solution, you should consider deleting your question and trying again. The Delete Question button is located near the text of your original post.

If you are not certain which selection to make, click the Request Attention button, and the Moderators will help you with the proper choice.
0
 

Author Closing Comment

by:njschenck
ID: 31507190
You are beyond helpful!  Thank you so much!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now