We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29076
    • 615 Posts
    I have a contact form based on smtp/Gmail. But there is a spam-robot sending in the name Timothywaw that I want to be blocked as sender.

    Is this possible?

    I use a Gmail-account as sender/smtp host/adresse, so all emails goes through the folder Sendt in that account. But it's not possible to make filters to the Sendt folders, so I figure I have to set in the Modx Formit setup.

    Modx Revo 2.7.0
    Formit latest.

            &emailTo=`[email protected]`
            &emailSubject=`Melding fra kontaktskjemaet på verketyoga.no`
            &fiarFrom=`[email protected]`
            &fiarFromName=`[email protected]`
          <form class="cmxform" id="contactForm" action="[[~[[*id]]]]" method="post">
            <input type="hidden" name="nospam:blank" value="[[+fi.nospam]]" />
      I think, thererfor I am! But what I am, and why...?
      • 42541
      • 18 Posts
      You can use FormIt &preHooks:

      [[!FormIt? &preHooks=`stopTheSpammers`]]

      and stopTheSpammers snippet code:

      $email = $hook->getValue('email'); // get email from a form that is actually sending
      $allFormFields = $hook->getValues();  // get all fields from that form to an array
      if (...) {
      ... // your filter code
      $errorMsg = 'Got ya spammer!';
      return false;
      } else {
      return true;

      return false stops the form and return true is continuing formit script.

      personally i would recommend some captcha systems i.e. google recaptcha.