Learn-to-send-email-via-google-script-html-no-server: How to exclude Honeypot value on submitted email?

Created on 7 Nov 2017  路  3Comments  路  Source: dwyl/learn-to-send-email-via-google-script-html-no-server

Since the script takes all the key names from the form submitted and sends it thru email, it also takes the honeypot key name. How do you exclude this? Thanks.

enhancement

Most helpful comment

Easy peasy, you just need to add in some code to make sure that the special item named honeypot is not stored in the fields variable. I would suggest using a filter before the map. Would look something like:

// here is the start of the line to edit, note you are adding in a filter before the map
var fields = Object.keys(elements).filter(function(k) {

        // the filtering logic is simple, only keep fields that are not the honeypot
        return (elements[k].name !== 'honeypot');

    // leave the rest of the code alone
    }).map(function(k) {
        // altering the data here
    }).filter(function(item, pos, self) {
        // more filtering going on here
    });

We could add some up to date instructions in the readme, anyone feel free to PR.

All 3 comments

Easy peasy, you just need to add in some code to make sure that the special item named honeypot is not stored in the fields variable. I would suggest using a filter before the map. Would look something like:

// here is the start of the line to edit, note you are adding in a filter before the map
var fields = Object.keys(elements).filter(function(k) {

        // the filtering logic is simple, only keep fields that are not the honeypot
        return (elements[k].name !== 'honeypot');

    // leave the rest of the code alone
    }).map(function(k) {
        // altering the data here
    }).filter(function(item, pos, self) {
        // more filtering going on here
    });

We could add some up to date instructions in the readme, anyone feel free to PR.

Yes, it worked! Thanks @mckennapsean.

this was merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mckennapsean picture mckennapsean  路  3Comments

onurusluca picture onurusluca  路  4Comments

tiffting picture tiffting  路  4Comments

Herbert2122 picture Herbert2122  路  4Comments

vlknlvnt picture vlknlvnt  路  4Comments