%@ LANGUAGE="VBSCRIPT" %>
<% option explicit %>
<% Response.Buffer = True %>
<%
'Declaring Variables
Dim smtpserver,youremail,yourpassword,ContactUs_Name,ContactUs_Email
Dim ContactUs_Subject,ContactUs_Body,Action,IsError
' Edit these 3 values accordingly.. leave the smtp server alone as it is set for Gmail
smtpserver = "smtp.gmail.com"
youremail = "smartpants6@gmail.com"
yourpassword = "cheese6%"
' Grabbing variables from the form post
ContactUs_Name = Request("ContactUs_Name")
ContactUs_Email = Request("ContactUs_Email")
ContactUs_Subject = Request("ContactUs_Subject")
ContactUs_Body = Request("ContactUs_Body")
Action = Request("Action")
' Used to check that the email entered is in a valid format
Function IsValidEmail(Email)
Dim ValidFlag,BadFlag,atCount,atLoop,SpecialFlag,UserName,DomainName,atChr,tAry1
ValidFlag = False
If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then
atCount = 0
SpecialFlag = False
For atLoop = 1 To Len(Email)
atChr = Mid(Email, atLoop, 1)
If atChr = "@" Then atCount = atCount + 1
If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True
If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True
If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True
If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True
Next
If (atCount = 1) And (SpecialFlag = False) Then
BadFlag = False
tAry1 = Split(Email, "@")
UserName = tAry1(0)
DomainName = tAry1(1)
If (UserName = "") Or (DomainName = "") Then BadFlag = True
If Mid(DomainName, 1, 1) = "." then BadFlag = True
If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True
ValidFlag = True
End If
End If
If BadFlag = True Then ValidFlag = False
IsValidEmail = ValidFlag
End Function
%>
Insane Food.com - Contact Us
|
Index
|
Recipes
|
Donate
|
Contact Us
|
|
Contact Us
<% If Action = "SendEmail" Then
' Here we quickly check/validate the information entered
' These checks could easily be improved to look for more things
If IsValidEmail(ContactUs_Email) = "False" Then
IsError = "Yes"
Response.Write("You did not enter a valid email address. ")
End If
If ContactUs_Name = "" Then
IsError = "Yes"
Response.Write("You did not enter a Name. ")
End If
If ContactUs_Subject = "" Then
IsError = "Yes"
Response.Write("You did not enter a Subject. ")
End If
If ContactUs_Body = "" Then
IsError = "Yes"
Response.Write("You did not enter a Body. ")
End If
End If
' If there were no input errors and the action of the form is "SendEMail" we send the email off
If Action = "SendEmail" And IsError <> "Yes" Then
Dim strBody
' Here we create a nice looking html body for the email
strBody = strBody & "Contact Us Form submitted at " & Now() & vbCrLf & "
"
strBody = strBody & "From http://" & Request.ServerVariables("HTTP_HOST") & vbCrLf & " "
strBody = strBody & "IP " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & " "
strBody = strBody & "Name" & " : " & " " & Replace(ContactUs_Name,vbCr," ") & " "
strBody = strBody & "Email" & " : " & " " & Replace(ContactUs_Email,vbCr," ") & " "
strBody = strBody & "Subject" & " : " & " " & Replace(ContactUs_Subject,vbCr," ") & " "
strBody = strBody & " " & Replace(ContactUs_Body,vbCr," ") & " "
strBody = strBody & ""
Dim Mail
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "mail.massmind.org"
Mail.From = "james@massmind.org"
Mail.FromName = "contactus"
Mail.AddAddress yourEmail
Mail.AddReplyTo ContactUs_Email, ContactUs_Name
Mail.Subject = ContactUs_Subject
Mail.Body = strBody
On Error Resume Next
Mail.Send
ContactUs_Body = err.description & ContactUs_Body
Set Mail = Nothing
' change the success messages below to say or do whatever you like
' you could do a response.redirect or offer a hyperlink somewhere.. etc etc
%>
Your message (as shown below) was sent and we will get back to you.
<% =Replace(ContactUs_Body,vbCr," ") %>
<% Else %>
<% End If %>
|
Inspiration for Site by Noah Maxin - Site by James Remington Orozco Newton
|
|