locked
Ideas for effective Contact Us anti-spam ? RRS feed

  • Question

  • User876561910 posted

    As test I put up a Contact Form yesterday with no anti spam.

    It has already been targeted by multiple (lots) of spam-bots.

    I have taken it down now.

     

    So has anyone come up with a good (and simple) method of stopping spam-bots from getting through.

    Honey-pot?
    ASP validation (must be empty) on a CSS visible=none text box (external file)?
    JS script?
    etc.

    I’d prefer to keep this client-side (as my hosts are a pain)


    Here is the type of very simple contact us form I’m looking to protect.

    Any ideas would be greatly appreciated



    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head runat="server">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Some title</title>
        <script>
            function aa()
            {
                window.location.href("message OK page .aspx") 
    
            }
            function error()
            {
                alert("ooops it all gone wrong"); 
            }
        </script>
    
    <script language="vbscript" type="text/vb" runat="server">
        Sub MyButton_Click(ByVal sender As Object, ByVal e As EventArgs)
            Try
                SendEmail()
                Page.ClientScript.RegisterStartupScript(Page.GetType(), " ", "aa()", True)
            Catch ex As Exception
                Page.ClientScript.RegisterStartupScript(Page.GetType(), " ", "error()", True)
            End Try
    
        End Sub
    
        Sub SendEmail()
            Dim SendResultsTo As String = "MyEmail@some.com"
            Dim smtpMailServer As String = "mySMTP settings"
            Dim smtpUsername As String = SendResultsTo
            Dim smtpPassword As String = "my SMTP password"
            Dim MailSubject As String = "Some title"
            Dim MailMessage As String = "From:  " & YourName.Text & vbCrLf & vbCrLf & "EMail:  " & YourEMail.Text & vbCrLf & vbCrLf & "Message:  " & Comments.Text
    
    
            Dim FromEmail As String = "MyEmail@some.com"
            Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
            myMessage.To.Add(SendResultsTo)
            myMessage.From = New System.Net.Mail.MailAddress(FromEmail)
            myMessage.Subject = MailSubject
            myMessage.Body = MailMessage
            myMessage.IsBodyHtml = False
            Dim MailObj As New System.Net.Mail.SmtpClient
            MailObj.Host = smtpMailServer
            MailObj.Credentials = New Net.NetworkCredential(smtpUsername, smtpPassword)
            MailObj.Send(myMessage)
        End Sub
    
    
    
    </script>
    
    </head>
    
    <body>
    
    <form id="form1" runat="server">
    
    <asp:Label runat="server" Text="Your name" id="LabName"></asp:Label>
    <br />
    <asp:TextBox ID="YourName" runat="server" Width="150px" />
    <br />
    <br />
    <asp:Label runat="server" Text="Your E Mail" id="LabMail"></asp:Label>
    <br />
    <asp:TextBox ID="YourEMail" runat="server" Width="150px" />
    <br />
    <br />
    <asp:Label runat="server" Text="Message" id="LabMessage"></asp:Label>
    <br />
    <asp:TextBox ID="Comments" runat="server" TextMode="MultiLine" Rows="10" Width="400px" />
    <br />
    <br /> 
    <asp:Button runat="server" Text="Send message" OnClick="MyButton_Click" id="Button1" ></asp:Button>	
    
    </form>
    
    </body>
    
    </html>
    



    Thursday, March 14, 2019 6:55 AM

All replies

  • User1120430333 posted

    Things to think about using....

    https://www.lifewire.com/solutions-to-protect-web-forms-from-spam-3467469

    Thursday, March 14, 2019 9:25 AM
  • User876561910 posted


    Has anyone tried this?

    Add another text box – named Email or something else which bots look for.

    Then do a simple If in the VBscript

    Like this

     

    Add this to the form (hidden by external CSS)

    <asp:TextBox ID="Email" runat="server"/>

    Then




    If Len (Email) = 0 Then
    
        Sub SendEmail()
            Dim SendResultsTo As String = "MyEmail@some.com"
            Dim smtpMailServer As String = "mySMTP settings"
            Dim smtpUsername As String = SendResultsTo
            Dim smtpPassword As String = "my SMTP password"
            Dim MailSubject As String = "Some title"
            Dim MailMessage As String = "From:  " & YourName.Text & vbCrLf & vbCrLf & "EMail:  " & YourEMail.Text & vbCrLf & vbCrLf & "Message:  " & Comments.Text
    
    
            Dim FromEmail As String = "MyEmail@some.com"
            Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
            myMessage.To.Add(SendResultsTo)
            myMessage.From = New System.Net.Mail.MailAddress(FromEmail)
            myMessage.Subject = MailSubject
            myMessage.Body = MailMessage
            myMessage.IsBodyHtml = False
            Dim MailObj As New System.Net.Mail.SmtpClient
            MailObj.Host = smtpMailServer
            MailObj.Credentials = New Net.NetworkCredential(smtpUsername, smtpPassword)
            MailObj.Send(myMessage)
    
    End If
    
    End Sub

    Thursday, March 14, 2019 11:55 AM
  • User409696431 posted

    I use google's recaptcha on several sites.  (https://www.google.com/recaptcha/intro/v3.html ) You need to check google's response in your code-behind before accepting the form submission.  I haven't seen bots get through.

    Friday, March 15, 2019 1:25 AM