0

I have a simple Classic ASP feedback form that suffers from SPAM. All code is client side and I believe the idea is to hide the email address from the BOTS. While I understand the honeypot concept in principle, I'm not understanding how to adapt the code below to accomplish this. Hoping for an relatively easy fix without having to modify extensively. Any help appreciated...

<% 
ErrorStatus = 0
ErrorMessage = ""
If Trim(Request("comment")) + "" = "" Then
    ErrorStatus = 1
    ErrorMessage = "Please provide a non-blank comment"
ElseIf Request("name") + "" = "" Then
    ErrorStatus = 2
    ErrorMessage = "Please provide a non-blank name"
ElseIf Trim(Request("email")) + "" = "" Then
    ErrorStatus = 3
    ErrorMessage = "Please provide a non-blank e-mail address"
ElseIf Trim(Request("email")) & "" <> "" and InStr(Request("email"),chr(64)) = 0 Then
    ErrorStatus = 4
    ErrorMessage = "Please enter a valid e-mail address"
End If
If ErrorStatus > 0 Then %>
<form action="feedback.asp" method="post">
<input type="hidden" name="action" value="send">
<br>
<FONT FACE="Arial, Helvetica, Verdana" COLOR="red"><b><DIV CLASS="h1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* <%= ErrorMessage %> *</DIV></b></FONT>
<br>
<FONT FACE="Arial, Helvetica, Verdana" COLOR="gainsboro">
<DIV CLASS="h2_30">
<p>Your Name:
<br>
<input name="name" size=35 value="<%= Request("name")%>">
<p>Your E-Mail Address:
<br>
<input name="email" size=35 value="<%= Request("email")%>">
<p>Your Comments:
<br>
<textarea name="comment" cols=50 rows=7><%= Request("comment") %></textarea>
<p><input type="submit" value="Send Mail">
</FONT>
</DIV>
<br>
<DIR>
<FONT FACE="Arial, Helvetica, Verdana" COLOR="#ffd700">
<DIV CLASS="h3">
<b>* All fields required</b>
</DIV>
</FONT>
</DIR>
</form>
<% Else  
  strBody = Request("comment") & Chr(13) & Chr(10) & Chr(13) & Chr(10)
  strBody = strBody & Request("name") & Chr(13) & Chr(10) & Request("email") & Chr(13) & Chr(10)

  Set objMessage = CreateObject("CDO.Message")
  objMessage.Sender =  Request("name")
  objMessage.From =  Request("email")
  objMessage.TextBody = strBody 
  objMessage.To = "[email protected]"
  objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
  objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  objMessage.Configuration.Fields.Update

  On Error Resume Next
  objMessage.Send

  Response.Write "<BR><FONT FACE=Arial, Helvetica, Verdana COLOR=gainsboro><DIV CLASS=h2_10B><DIV CLASS=h2_10B><DIV CLASS=h2_10B><p>Feedback Sent!</p></DIV></DIV></DIV></FONT>"
  set objMessage = nothing

  End If %>
<% End Sub %>
<% Sub GetInfo %>
5
  • your email is not visible - you probably ask how to avoid spam email send - right ? - and there is always the google captcha
    – Aristos
    Commented Apr 8, 2021 at 2:13
  • 1
    Google Captcha V3 doesn't require the user to select all busses, traffic lights etc. It works in the background so it's much more user friendly than V2.
    – VDWWD
    Commented Apr 8, 2021 at 6:31
  • Correct, I'm trying to avoid SPAM email originating from the form.
    – sverdina
    Commented Apr 8, 2021 at 6:37
  • Does this answer your question? .asp honeypot for contact form
    – user692942
    Commented Apr 8, 2021 at 8:14
  • Having On Error Resume Next in a script isn't generally recommended
    – John
    Commented Apr 8, 2021 at 20:54

0

Browse other questions tagged or ask your own question.