Ver Mensaje Individual
  #9 (permalink)  
Antiguo 08/08/2002, 14:47
Avatar de Grayman
Grayman
 
Fecha de Ingreso: junio-2002
Ubicación: No, en realidad, vivo desubicado.
Mensajes: 43
Antigüedad: 22 años, 10 meses
Puntos: 0
Re: Configuración de formmail

<%@ LANGUAGE="VBScript" %>

<% '************************************************* **************************
'* ASP FormMail *
'* *
'* Copyright 1999, 2000 by Mike Hall. *
'* Please see http://www.brainjar.com for documentation and terms of use. *
'************************************************* **************************

'- Customization of these values is required, see documentation. -----------

referers = Array("www.rosariocentral.com", "rosariocentral.com")
mailComp = "CDONTS"
smtpServer = "smtp.rosariocentral.com"
fromAddr = "[email protected]"

'- End required customization section. -------------------------------------

Response.Buffer = true
errorMsgs = Array()

'Check for form data.

if Request.ServerVariables("Content_Length" ) = 0 then
call AddErrorMsg("No form data submitted.")
end if

'Check if referer is allowed.

validReferer = false
referer = GetHost(Request.ServerVariables("HTTP_REFERER "))
for each host in referers
if host = referer then
validReferer = true
end if
next
if not validReferer then
if referer = "" then
call AddErrorMsg("No referer.")
else
call AddErrorMsg("Invalid referer: '" & referer & "'.")
end if
end if

'Check for the recipients field.

if Request.Form("_recipients") = "" then
call AddErrorMsg("Missing email recipient.")
end if

'Check all recipient email addresses.

recipients = Split(Request.Form("_recipients"), ",")
for each name in recipients
name = Trim(name)
if not IsValidEmail(name) then
call AddErrorMsg("Invalid email address in recipient list: " & name & ".")
end if
next
recipients = Join(recipients, ",")

'Get replyTo email address from specified field if given and check it.

name = Trim(Request.Form("_replyToField"))
if name <> "" then
replyTo = Request.Form(name)
else
replyTo = Request.Form("_replyTo")
end if
if replyTo <> "" then
if not IsValidEmail(replyTo) then
call AddErrorMsg("Invalid email address in reply-to field: " & replyTo & ".")
end if
end if

'Get subject text.

subject = Request.Form("_subject")

'If required fields are specified, check for 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 = "<table border=0 cellpadding=2 cellspacing=0>" & vbCrLf
for each name in fieldOrder
body = body _
& "<tr valign=top>" _
& "<td><font face=""Arial,Helvetica"" size=2><b>" _
& name _
& ": </b></font></td>" _
& "<td><font face=""Arial,Helvetica"" size=2>" _
& Request.Form(name) _
& "</font></td>" _
& "</tr>" & vbCrLf
next
body = body & "</table>" & vbCrLf

'Add a table with any environmental variables.

if Request.Form("_envars") <> "" then
body = body _
& "<p>" _
& "<table border=0 cellpadding=2 cellspacing=0>" & vbCrLf
envars = Split(Request.Form("_envars"), ",")
for each name in envars
name = Trim(name)
body = body _
& "<tr valign=top>" _
& "<td><font face=""Arial,Helvetica"" size=2><b>" _
& name _
& ": </b></font></td>" _
& "<td><font face=""Arial,Helvetica"" size=2>" _
& Request.ServerVariables(name) _
& "</font></td>" _
& "</tr>" & vbCrLf
next
body = body & "</table>" & vbCrLf
end if

'Send it.

str = SendMail()
if str <> "" then
AddErrorMsg(str)
end if

'Redirect if a URL was given.

if Request.Form("_redirect") <> "" then
Response.Redirect(Request.Form("_redirect&quo t;))
end if

end if %>