Skip to main content
January 27, 2010
Question

Avoiding spam on "Send to a Friend" features.

  • January 27, 2010
  • 1 reply
  • 496 views

I know this is not specifically a CF question, but a my sites are built in CF, and hence could leverage a CF solution.

Any tips on how to avoid abuse when offering a "send to a friend" feature that sends an email to a nominated recipient. I have a captcha with it but I am looking for a little inspiration on how to minimize the risk further.

Cheers.

    This topic has been closed for replies.

    1 reply

    January 28, 2010

    Store the number of send attempts by the sender in a new table and limit the number of sends based on a max count limit within a specified period of time, say within the last 24 hours.

    New table, tableSends:

    column1: senderAccountId

    colun2: recipientAccountId

    column3: timestamp

    <cfset max_send_count = 2>

    <cfquery name="qry1">

         SELECT COUNT(*) result

         FROM tableSends

         WHERE senderAccountId = '123' AND recipientAccountId = '999'

         AND DATEDIFF('h', timestamp, GETEDATE()) < 24

    </cfquery>

    <cfoutput>

         <cfif qry1.result LTE max_send_count>

              <!---Send another--->

              <!---Record send to the database table tableSends--->

         <cfelse>

             <!---You've reached the maximum allowed invites--->

         </cfif>

    </cfoutput>

    For a pure CF solution with no database, instead of storing variables in the new table below, store them into the CLIENT scope and set that scope's storage to REGISTRY in the server admin and set the purge interval to 24 hours.

    <cfset CLIENT.sendRecords = "#senderAccountId#",'#recipientAccountId#','#timestamp#'>

    ...and use...

    <cfif IsDefined("CLIENT.sendRecords") AND ListFind(senderAccountId, CLIENT.sendRecords)>

    </cfif>

    Good Luck!

    January 30, 2010

    Thanks NateDog!!