We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11449
    • 28 Posts
    So I'm using FormIt for a simple contact form on a clients site. They want to be able to edit a list of options for who the form sends too. So I figured I would use a migx tv where they can add a name and email for each option, then have that placed into the form.

    I saw that on the FormIt email hook page there is an example for dynamic to Addresses
    [[!FormIt?
       &emailTo=`[[+addressTo]]`
    ]]
    ...
    <select name="addressTo">
       <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>John</option>
       <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>Jane</option>
    </select>


    But this system has the email addresses in the HTML where they can be crawled quite easily by spam bots. Is there some other more spam-proof way to offer this, where the actual addresses are not stored anywhere in the HTML page?

    I had thought of using the migx IDX value somehow in the select, and then seing if its posible to use getImageList in the FormIt &emailTo=`` that only grabs the email from the migx tv with the suplied IDX. This is all over my head though.

    This question has been answered by guategeek. See the first response.

      • 3749
      • 24,544 Posts
      If it's a contact form, you might take a look at SPForm. It's much easier to set up than FormIt, very spam-proof, and it never exposes any of the email addresses, though it's not a flexible as FormIt.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 11449
        • 28 Posts
        Ah that's a drag, as I already have everything set up with Formit and working great, except for selecting an email to send too.

        I had even tried using output filters on the GetImageList call to mirror the addresses, and swap out the @ and . characters with other ones. Then I was going to use another output filter on the FormIt emailTo to return them to normal. But if I put anything besides a plain feild tag it won't work.

        This works, but you have to have full email addresses in your HTML
        [[!FormIt?
           &emailTo=`[[+addressTo]]`
        ]]
        


        This was what I wanted to do but it dousn't work
        [[!FormIt?
           &emailTo=`[[+addressTo:reverse:replace=`#==@`:replace=`*==.`]]`
        ]]
        
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          You could scramble it for the resource, then use Javascript to fix it for the form field. It would still be easy enough to discover the real email address, but then the best you can do is to slow down the automated scrapers as much as possible anyway.

          Or maybe a custom hook, to be used before the email hook, that fixes it after submission? In that case, you wouldn't need to have anything even approximating a valid email address in the form.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
          • discuss.answer
            • 11449
            • 28 Posts
            Thanks for your help guys, I ended up writing my own hook to unscramble the email on form submission, allowing me to have nothing even close to an email in the page. Here is my hook I'm not a PHP guy so I know its ugly. I realized latter I could probably have used the same variable the whole way through.
            <?php
            // Get the inquiry value
            $getaddress = $hook->getValue('person');
            // Reformat it to a normal address
            $reverseaddress = strrev($getaddress);
            $replaceat = str_replace("^", "@", $reverseaddress);
            $replacedot = str_replace("*", ".", $replaceat);
            // output the corected email address to a form value emailto
            $hook->setValue('emailto', $replacedot);
            
            return true;    // Needed for the form to validate
            


            I used output filters in the form to scramble the addresses from the MIGX TV that generates the list of possible addresses the form can go to.