%@ LANGUAGE="VBScript" %>
<% '**************************************************************************
'* ASP FormMail *
'* *
'* Do not remove this notice. *
'* *
'* Copyright 1999-2008 by Mike Hall. *
'* Please see http://www.brainjar.com for documentation and terms of use. *
'**************************************************************************
'- Customization of these values is required, see documentation. ----------
mailComp = "ASPMail"
smtpServer = "mail.toninos.com"
fromAddr = "info@toninos.com"
allowedHosts = Array("www.toninos.com", "toninos.com")
allowedRecipients = Array()
allowedEnvars = Array("HTTP_USER_AGENT", "REMOTE_ADDR", "REMOTE_USER")
allowCcToFlag = true
botCheckFlag = false
botCheckID = "MyBotCheckID"
botCheckMinTime = 5
'- End required customization section. ------------------------------------
'Initialize.
Response.Buffer = true
errorMsgs = Array()
'Check for form data.
if Request.ServerVariables("Content_Length") = 0 then
call AddErrorMsg("No form data submitted.")
end if
'If bot checking is enabled, check the elapsed time.
if botCheckFlag then
startTime = Session(botCheckID)
if not IsDate(startTime) then
call AddErrorMsg("Invalid submission.")
elseif DateDiff("s", startTime, Now()) < botCheckMinTime then
call AddErrorMsg("Invalid submission.")
end if
end if
'Check if the referering host is allowed.
if UBound(allowedHosts) >= 0 then
host = GetHost(Request.ServerVariables("HTTP_REFERER"))
if host = "" then
call AddErrorMsg("No referer.")
elseif not InList(host, allowedHosts) then
call AddErrorMsg("Unauthorized host: '" & host & "'.")
end if
end if
'Check the email recipients.
if Request.Form("_recipients") = "" then
call AddErrorMsg("No email recipient(s) specified.")
else
recipients = Split(Request.Form("_recipients"), ",")
for each addr in recipients
addr = Trim(addr)
if not IsValidEmailAddress(addr) then
call AddErrorMsg("Invalid email address in recipient list: " & addr & ".")
elseif UBound(allowedRecipients) >= 0 then
if not inList(addr, allowedRecipients) then
call AddErrorMsg("Unauthorized email address in recipient list: " & addr & ".")
end if
end if
next
recipients = Join(recipients, ",")
end if
'Check for a cc-to or reply-to address.
ccToAddr = ""
replyToAddr = ""
name = Trim(Request.Form("_ccToField"))
if name <> "" then
if not allowCcToFlag then
call AddErrorMsg("Configuration error: use of _ccToField not permitted.")
else
ccToAddr = Request.Form(name)
if ccToAddr <> "" then
if not IsValidEmailAddress(ccToAddr) then
call AddErrorMsg("Invalid email address in " & name & " field: " & ccToAddr & ".")
end if
end if
end if
else
name = Trim(Request.Form("_replyToField"))
if name <> "" then
replyToAddr = Request.Form(name)
if replyToAddr <> "" then
if not IsValidEmailAddress(replyToAddr) then
call AddErrorMsg("Invalid email address in " & name & " field: " & replyToAddr & ".")
end if
end if
end if
end if
'Get the subject text.
subject = Request.Form("_subject")
'If required fields are specified, check them.
if Request.Form("_requiredFields") <> "" then
required = Split(Request.Form("_requiredFields"), ",")
for each name in required
name = Trim(name)
if Left(name, 1) <> "_" and Request.Form(name) = "" then
call AddErrorMsg("Missing value for " & name)
end if
next
end if
'If a field order was given, use it. Otherwise use the order the fields
'were received in.
str = ""
if Request.Form("_fieldOrder") <> "" then
fieldOrder = Split(Request.Form("_fieldOrder"), ",")
for each name in fieldOrder
if str <> "" then
str = str & ","
end if
str = str & Trim(name)
next
fieldOrder = Split(str, ",")
else
fieldOrder = FormFieldList()
end if
'If there were no errors, build the email note and send it.
if UBound(errorMsgs) < 0 then
'Build table of form fields and values.
body = "
" & vbCrLf
for each name in fieldOrder
body = body _
& "
" _
& "
" & name & ":
" _
& "
" & Request.Form(name) & "
" _
& "
" & vbCrLf
next
body = body & "
" & vbCrLf
'Add a table for any requested environment variables.
if Request.Form("_envars") <> "" then
body = body _
& "
" & vbCrLf _
& "
" & vbCrLf
envars = Split(Request.Form("_envars"), ",")
for each name in envars
name = Trim(name)
'Only show environment variables in the permitted list.
showEnvar = true
if UBound(allowedEnvars) >= 0 then
showEnvar = InList(name, allowedEnvars)
end if
if showEnvar then
body = body _
& "
" _
& "
" & name & ":
" _
& "
" & Request.ServerVariables(name) & "
" _
& "
" & vbCrLf
end if
next
body = body & "
" & vbCrLf
end if
'Send it.
str = SendMail()
if str <> "" then
AddErrorMsg(str)
else
'Clear the bot check timestamp.
Session.Contents.Remove(botCheckID)
'Redirect if a URL was given.
if Request.Form("_redirectUrl") <> "" then
Response.Redirect(Request.Form("_redirectUrl"))
end if
end if
end if %>
Tonino's Trattoria Italian Restaurant of Jacksonville, Florida