<%
default_failure = Request.ServerVariables("URL")
default_details = True
default_whythank = True
default_thankspage = Request.ServerVariables("URL")
default_mailtype = "Text"
default_sender = Empty
default_sendername = Empty
default_recipient = Empty
default_subject = Empty
default_message = Empty
' Global Configuration
global_post_method_only = True
global_failure = Empty
global_details = Empty
global_whythank = Empty
global_thankspage = Empty
global_mailtype = Empty
global_sender = Empty
global_sendername = Empty
global_recipient = Empty
global_subject = Empty
global_message = Empty
form_sender = Trim(request("sender"))
form_sendername = request("sendername")
form_recipient = Trim(request("recipient"))
form_recipientname = request("recipientname")
form_subject = request("subject")
form_message = request("message")
form_thankspage = request("thankspage")
form_whythank = request("whythank")
form_mailtype = request("mailtype")
form_failure = request("failure")
form_details = request("details")
If global_sender = Empty Then
If form_sender = Empty Then
email_sender = default_sender
Else
email_sender = form_sender
End If
Else
email_sender = global_sender
End If
If global_sendername = Empty Then
If form_sendername = Empty Then
email_sendername = default_sendername
Else
email_sendername = form_sendername
End If
Else
email_sendername = global_sendername
End If
If global_recipient = Empty Then
If form_recipient = Empty Then
email_recipient = default_recipient
Else
email_recipient = form_recipient
End If
Else
email_recipient = global_recipient
End If
If global_recipientname = Empty Then
If form_recipientname = Empty Then
email_recipientname = default_recipientname
Else
email_recipientname = form_recipientname
End If
Else
email_recipientname = global_recipientname
End If
If global_subject = Empty Then
If form_subject = Empty Then
email_subject = default_subject
Else
email_subject = form_subject
End If
Else
email_subject = global_subject
End If
If global_message = Empty Then
If form_message = Empty Then
email_message = default_message
Else
email_message = form_message
End If
Else
email_message = global_message
End If
If global_thankspage = Empty Then
If form_thankspage = Empty Then
email_thankspage = default_thankspage
Else
email_thankspage = form_thankspage
End If
Else
email_thankspage = global_thankspage
End If
If global_whythank = Empty Then
If form_whythank = Empty Then
email_whythank = default_whythank
Else
email_whythank = form_whythank
If CStr(email_whythank) = "1" Then email_whythank = True
End If
Else
email_whythank = global_whythank
End If
If global_mailtype = Empty Then
If form_mailtype = Empty Then
email_mailtype = default_mailtype
Else
email_mailtype = form_mailtype
End If
Else
email_mailtype = global_mailtype
End If
If global_failure = Empty Then
If form_failure = Empty Then
email_failure = default_failure
Else
email_failure = form_failure
End If
Else
email_failure = global_failure
End If
If global_details = Empty Then
If form_details = Empty Then
email_details = default_details
Else
email_details = form_details
If CStr(email_details) = "1" Then email_details = True
End If
Else
email_details = global_details
End If
'determin whether to user will need to be redirected for failures or sucesses
off_page_failure_redirect = True
If email_failure = Request.ServerVariables("URL") Or email_failure = "" Then off_page_failure_redirect = False
off_page_thankspage_redirect = True
If email_thankspage = Request.ServerVariables("URL") Or email_thankspage = "" Then off_page_thankspage_redirect = False
process_email = True
'post method check
If global_post_method_only = True And LCase(Request.ServerVariables("REQUEST_METHOD")) <> "post" Then
If off_page_failure_redirect = True Then
Response.Redirect(email_failure & "?prob=post")
Else
process_email = False
prob = "post"
End If
End If
'check that there is a 'valid' email address for the "sender" and "recipient" fields
If Len(email_sender) < 5 Or Instr(email_sender, "@") < 2 Or Instr(email_sender, ".") < 4 Then
If off_page_failure_redirect = True Then
Response.Redirect(email_failure & "?prob=sender")
Else
process_email = False
prob = "sender"
End If
End If
If Len(email_recipient) < 5 Or Instr(email_recipient, "@") < 2 Or Instr(email_recipient, ".") < 4 Then
If off_page_failure_redirect = True Then
Response.Redirect(email_failure & "?prob=recipient")
Else
process_email = False
prob = "recipient"
End If
End If
'reformat values
If email_sendername = "" Then
email_from = email_sender
Else
email_from = email_sendername & "<" & email_sender & ">"
End If
If email_subject = "" Then email_subject = "No Subject"
If email_message = "" Then email_message = "No message"
'create details insert
If email_details = True Then
If LCase(email_mailtype) = "html" Then str_line = "<hr>" Else str_line = "---" & vbCrLf
insert_details = vbcrlf & vbcrlf & vbcrlf & str_line & "Remote Client: " & request.ServerVariables("REMOTE_ADDR") & vbcrlf & "Submitting Page: " & request.ServerVariables("HTTP_REFERER") & vbcrlf & "Processing Script: " & Request.ServerVariables("URL") & vbcrlf & "Sent Time/Date: " & FormatDateTime(Now,1) & ", " & Time
End If
'send email
If process_email <> False Then
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = email_from
objNewMail.Subject = email_subject
objNewMail.To = email_recipient
If LCase(email_mailtype) = "html" Then
objNewMail.BodyFormat = 0
objNewMail.MailFormat = 0
objNewMail.Body = Replace(Server.HTMLEncode(email_message), vbCrLf, "<br>") & Replace(insert_details, vbCrLf, "<br>")
Else
objNewMail.Body = email_message & insert_details
End If
objNewMail.Send
Set objNewMail = Nothing
'say thanks!
If off_page_thankspage_redirect = True Then
If email_whythank = True Then
Response.Redirect(email_thankspage & "?sender=" & email_sender & "&sendername=" & email_sendername & "&recipient=" & email_recipient & "&recipientname=" & email_recipientname & "&subject=" & email_subject & "&message=" & email_message)
Else
Response.Redirect(email_thankspage)
End If
End If
End If
%>
<html>
<head>
<title>Submit Response</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td colspan="3"><b><font face="Arial, Helvetica, sans-serif" size="5">
<% If process_email = False Then %>
There was a problem sending your email!
<% Else %>
Email sent successfully!
<% End If %>
</font></b></td></tr>
<tr><td colspan="3" height="10"></td></tr>
<tr><td colspan="3"><b><font face="Arial, Helvetica, sans-serif" size="4">Details:</font></b></td></tr>
<% If process_email <> False Then %>
<tr><td width="100" valign="top"><div align="right"><font face="Arial, Helvetica, sans-serif" size="3"><b>To:</b></font></div></td><td width="15"></td><td width="645"><font size="3" face="Courier New, Courier, mono"><%= email_recipientname & " &lt;" & email_recipient & "&gt;" %></font></td></tr>
<tr><td width="100" valign="top"><div align="right"><font face="Arial, Helvetica, sans-serif" size="3"><b>From:</b></font></div></td><td width="15"></td><td width="645"><font size="3" face="Courier New, Courier, mono"><%= email_sendername & " &lt;" & email_sender & "&gt;" %></font></td></tr>
<tr><td width="100" valign="top"><div align="right"><font face="Arial, Helvetica, sans-serif" size="3"><b>Subject:</b></font></div></td><td width="15"></td><td width="645"><font size="3" face="Courier New, Courier, mono"><%= email_subject %></font></td></tr>
<tr><td width="100" valign="top"><div align="right"><font face="Arial, Helvetica, sans-serif" size="3"><b>Sent as:</b></font></div></td><td width="15"></td><td width="645"><font size="3" face="Courier New, Courier, mono"><%= email_mailtype %></font></td></tr>
<tr><td width="100" valign="top"><div align="right"><font face="Arial, Helvetica, sans-serif" size="3"><b>Message:</b></font></div></td><td width="15"></td><td width="645"><font size="3" face="Courier New, Courier, mono"><%= Replace(Server.HTMLEncode(email_message),Chr(13),"<br>") %></font></td></tr>
<% Else
If prob = "sender" Then %>
<tr><td colspan="3"><font face="Arial, Helvetica, sans-serif" size="3"><b>There was a problem with the senders address, please go back and try again.</b></font></td></tr>
<% End If
End If %>
</table>
</body>
</html>