%@ 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, required, subject, strEmail1, strEmail2
Dim customer_id, date_day, date_month, date_year, brides_name, grooms_name, phone_day, email, married_name
Dim bride_parents, bride_grandparents, bride_flower_girl, bride_maid_of_honor, bride_bridesmaid01, bride_bridesmaid02, bride_bridesmaid03, bride_bridesmaid04, bride_bridesmaid05, bride_bridesmaid06, bride_bridesmaid07, bride_bridesmaid08, groom_parents, groom_grandparents, groom_ring_bearer, groom_best_man, groom_groomsman01, groom_groomsman02, groom_groomsman03, groom_groomsman04, groom_groomsman05, groom_groomsman06, groom_groomsman07, groom_groomsman08
Dim blessing, toasting01, toasting02, other_speaker01, other_speaker02, other_speaker03
Dim wedding_planner_name, wedding_planner_phone, wedding_planner_company, wedding_planner_email
Dim dj_playlist, dj_can_choose_when_to_play_songs, dj_can_take_requests, dj_can_play_explicit_songs, dj_must_follow_instructions_explicitly, song_announcing_bridal_party, song_bride_groom_entrance, song_first_dance, song_bride_father_dance, song_groom_mother_dance, song_cake_cutting, song_bouquet_toss_garter, song_money_dance, song_other_requests, song_do_not_play
Dim ceremony, ceremony_music_mood, ceremony_preprocessional, ceremony_groom_entrance, ceremony_brides_maids_entrance, ceremony_brides_entrance, ceremony_music01, ceremony_music02, ceremony_music03, ceremony_music04, ceremony_music05, ceremony_recessional, ceremony_notes
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.megaeventproduction.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.megaeventproduction.com","megaeventproduction.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
'----------------------------------------------------------------------------------------------------
%>
<%
'----------------------------------------------------------------------------------------------------
'retrieved default fields
'----------------------------------------------------------------------------------------------------
recipient = request("recipient")
redirect = request("redirect")
subject = request("subject")
email = request("email")
customer_id = request("customer_id")
date_day = request("date_day")
date_month = request("date_month")
date_year = request("date_year")
phone_day = request("phone_day")
brides_name = request("brides_name")
grooms_name = request("grooms_name")
married_name = request("married_name")
bride_parents = request("bride_parents")
bride_grandparents = request("bride_grandparents")
bride_flower_girl = request("bride_flower_girl")
bride_maid_of_honor = request("bride_maid_of_honor")
bride_bridesmaid01 = request("bride_bridesmaid01")
bride_bridesmaid02 = request("bride_bridesmaid02")
bride_bridesmaid03 = request("bride_bridesmaid03")
bride_bridesmaid04 = request("bride_bridesmaid04")
bride_bridesmaid05 = request("bride_bridesmaid05")
bride_bridesmaid06 = request("bride_bridesmaid06")
bride_bridesmaid07 = request("bride_bridesmaid07")
bride_bridesmaid08 = request("bride_bridesmaid08")
groom_parents = request("groom_parents")
groom_grandparents = request("groom_grandparents")
groom_ring_bearer = request("groom_ring_bearer")
groom_best_man = request("groom_best_man")
groom_groomsman01 = request("groom_groomsman01")
groom_groomsman02 = request("groom_groomsman02")
groom_groomsman03 = request("groom_groomsman03")
groom_groomsman04 = request("groom_groomsman04")
groom_groomsman05 = request("groom_groomsman05")
groom_groomsman06 = request("groom_groomsman06")
groom_groomsman07 = request("groom_groomsman07")
groom_groomsman08 = request("groom_groomsman08")
blessing = request("blessing")
toasting01 = request("toasting01")
toasting02 = request("toasting02")
other_speaker01 = request("other_speaker01")
other_speaker02 = request("other_speaker02")
other_speaker03 = request("other_speaker03")
wedding_planner_name = request("wedding_planner_name")
wedding_planner_phone = request("wedding_planner_phone")
wedding_planner_company = request("wedding_planner_company")
wedding_planner_email = request("wedding_planner_email")
dj_playlist = request("dj_playlist")
dj_can_choose_when_to_play_songs = request("dj_can_choose_when_to_play_songs")
dj_can_take_requests = request("dj_can_take_requests")
dj_can_play_explicit_songs = request("dj_can_play_explicit_songs")
dj_must_follow_instructions_explicitly = request("dj_must_follow_instructions_explicitly")
song_announcing_bridal_party = request("song_announcing_bridal_party")
song_bride_groom_entrance = request("song_bride_groom_entrance")
song_first_dance = request("song_first_dance")
song_bride_father_dance = request("song_bride_father_dance")
song_groom_mother_dance = request("song_groom_mother_dance")
song_cake_cutting = request("song_cake_cutting")
song_bouquet_toss_garter = request("song_bouquet_toss_garter")
song_money_dance = request("song_money_dance")
song_other_requests = request("song_other_requests")
song_do_not_play = request("song_do_not_play")
ceremony = request("ceremony")
ceremony_music_mood = request("ceremony_music_mood")
ceremony_preprocessional = request("ceremony_preprocessional")
ceremony_groom_entrance = request("ceremony_groom_entrance")
ceremony_brides_maids_entrance = request("ceremony_brides_maids_entrance")
ceremony_brides_entrance = request("ceremony_brides_entrance")
ceremony_music01 = request("ceremony_music01")
ceremony_music02 = request("ceremony_music02")
ceremony_music03 = request("ceremony_music03")
ceremony_music04 = request("ceremony_music04")
ceremony_music05 = request("ceremony_music05")
ceremony_recessional = request("ceremony_recessional")
ceremony_notes = request("ceremony_notes")
required = request("required")
if required = "" then
required = "recipient,subject,email,redirect"
else
required = "recipient,subject,email,redirect," & required
end if
'----------------------------------------------------------------------------------------------------
'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
'----------------------------------------------------------------------------------------------------
'verify the recipient(not tested)
'----------------------------------------------------------------------------------------------------
'trimed_referer = split(referer(2),".")'
'response.write recipient & "
" & referer(2) & "=" & trimed_referer(0) & "
"
'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 = "You have a new Wedding Form from: " & referer(2) & vbnewline &"-------------------------------------------------------------------------------------------" & vbnewline & vbnewline & "1. Your Information" & vbnewline & vbnewline & "MEGA Customer ID: " & customer_id & vbnewline & vbnewline & "Bride's Name: " & brides_name & vbnewline & "Groom's Name: " & grooms_name & vbnewline & vbnewline & "Event Date: " & date_day & " " & date_month & " " & date_year & vbnewline & vbnewline & "E-Mail: " & email & vbnewline & vbnewline & "Phone (Day): " & phone_day & vbnewline & vbnewline & "Married Name: " & married_name & vbnewline & vbnewline & vbnewline & "2. Your Guests" & vbnewline & vbnewline & "Bride: " & vbnewline & "Parents: " & bride_parents & vbnewline & "Grand Parents: " & bride_grandparents & vbnewline & "Flower Girl: " & bride_flower_girl & vbnewline & "Maid Of Honor: " & bride_maid_of_honor & vbnewline & "Bride's Maid 01: " & bride_bridesmaid01 & vbnewline & "Bride's Maid 02: " & bride_bridesmaid02 & vbnewline & "Bride's Maid 03: " & bride_bridesmaid03 & vbnewline & "Bride's Maid 04: " & bride_bridesmaid04 & vbnewline & "Bride's Maid 05: " & bride_bridesmaid05 & vbnewline & "Bride's Maid 06: " & bride_bridesmaid06 & vbnewline & "Bride's Maid 07: " & bride_bridesmaid07 & vbnewline & "Bride's Maid 08: " & bride_bridesmaid08 & vbnewline & vbnewline & "Groom: " & vbnewline & "Parents: " & groom_parents & vbnewline & "Grand Parents: " & groom_grandparents & vbnewline & "Ring Bearer: " & groom_ring_bearer & vbnewline & "Best Man: " & groom_best_man & vbnewline & "Groom's Man 01: " & groom_groomsman01 & vbnewline & "Groom's Man 02: " & groom_groomsman02 & vbnewline & "Groom's Man 03: " & groom_groomsman03 & vbnewline & "Groom's Man 04: " & groom_groomsman04 & vbnewline & "Groom's Man 05: " & groom_groomsman05 & vbnewline & "Groom's Man 06: " & groom_groomsman06 & vbnewline & "Groom's Man 07: " & groom_groomsman07 & vbnewline & "Groom's Man 08: " & groom_groomsman08 & vbnewline & vbnewline & vbnewline & "3. Your Speakers" & vbnewline & vbnewline & "Blessing: " & blessing & vbnewline & "Toasting 01: " & toasting01 & vbnewline & "Toasting 02: " & toasting02 & vbnewline & "Other Speaker 01: " & other_speaker01 & vbnewline & "Other Speaker 02: " & other_speaker02 & vbnewline & "Other Speaker 03: " & other_speaker03 & vbnewline & vbnewline & vbnewline & "4. Your Wedding Planner/Coordinator" & vbnewline & vbnewline & "Name: " & wedding_planner_name & vbnewline & "Company: " & wedding_planner_company & vbnewline & "Phone: " & wedding_planner_phone & vbnewline & "EMail: " & wedding_planner_email & vbnewline & vbnewline & vbnewline & "5. Your Reception Music" & vbnewline & vbnewline & "DJ Can Decide What To Play: " & dj_playlist & vbnewline & "DJ Can Choose When To Play Songs: " & dj_can_choose_when_to_play_songs & vbnewline & "DJ Can Take Requests From Guests: " & dj_can_take_requests & vbnewline & "DJ Can Play Explicit Songs: " & dj_can_play_explicit_songs & vbnewline & "DJ Must Follow Instructions Explicitly: " & dj_must_follow_instructions_explicitly & vbnewline & vbnewline & "Key Songs: " & vbnewline & vbnewline & "While Announcing Bridal Party: " & song_announcing_bridal_party & vbnewline & "Bride & Groom Entrance: " & song_bride_groom_entrance & vbnewline & "First Dance: " & song_first_dance & vbnewline & "Bride / Father Dance: " & song_bride_father_dance & vbnewline & "Groom / Mother Dance: " & song_groom_mother_dance & vbnewline & "Cake Cutting Song: " & song_cake_cutting & vbnewline & "Bouquet Toss / Garter: " & song_bouquet_toss_garter & vbnewline & "Money Dance: " & song_money_dance & vbnewline & "Other Requests: " & song_other_requests & vbnewline & "Do Not Play: " & song_do_not_play & vbnewline & vbnewline & "I Need A Ceremony Package: " & ceremony & vbnewline & vbnewline & vbnewline & "6. Your Ceremony Music" & vbnewline & vbnewline & "Mood: " & ceremony_music_mood & vbnewline & "Pre-Processional: " & ceremony_preprocessional & vbnewline & "Groom's Entrance: " & ceremony_groom_entrance & vbnewline & "Bride's Maids Entrance: " & ceremony_brides_maids_entrance & vbnewline & "Bride's Entrance: " & ceremony_brides_entrance & vbnewline & "Ceremony Music 01: " & ceremony_music01 & vbnewline & "Ceremony Music 02: " & ceremony_music02 & vbnewline & "Ceremony Music 03: " & ceremony_music03 & vbnewline & "Ceremony Music 04: " & ceremony_music04 & vbnewline & "Ceremony Music 05: " & ceremony_music05 & vbnewline & "Recessional: " & ceremony_recessional & vbnewline & "Suggestions / Notes: " & ceremony_notes & vbnewline & vbnewline & vbnewline & strBody & vbnewline
'----------------------------------------------------------------------------------------------------
'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:")& "
"
response.write("error no.: ")&err.number & "
"
response.write("description: ")&err.description & "
"
response.end
End If
On Error Goto 0
'----------------------------------------------------------------------------------------------------
'send them to the page specified
'----------------------------------------------------------------------------------------------------
Response.Redirect redirect
'####################################################################################################
'This is where the code ends
'####################################################################################################
%>