Help - Search - Members - Calendar
Full Version: how to avoid spam in emails?
HTMLHelp Forums > Programming > Server-side Scripting
rrn
in my website i have made a form for sending emails .. i have also done the code for sending emails to my id ...
its working fine , am receiving emails...but the problem is that , i am also receiving spam emails...how can i pevent spam emails reaching my mail id??????

any help will be appreciated........
Brian Chandler
You need to stop (or try to stop) spambots using your form. One problem is that standard CAPTCHA stuff has been broken, so is not effective.


Assuming it's a real script that handles them, simplest thing is to add some check that's personalised to your page. For example, if your name is Fred Popowitz, and it's your personal site, any real person wanting to send you mail will know your name. So you add a spam-block field to the form

Please type my family name [P___]

and reject the submission unless it matches.
geoffmerritt
If you don't want urls sent in your form, this code will check the string for 'http', which are in all spam emails and if detected will stop the script.

CODE
    
$spamerrormessage = "A web site URL has been detected, the form submission has been cancelled";
    
    if (preg_match("/http/i", "$name"))
        {
        echo " $spamerrormessage";
        exit();
        }


Brian Chandler
QUOTE(geoffmerritt @ Jul 14 2009, 11:42 PM) *

If you don't want urls sent in your form, this code will check the string for 'http', which are in all spam emails and if detected will stop the script.


Unfortunately this produces huge numbers of false positives, since lots of genuine emails also include URLs.

FWIW, I'm using PHPBBS for a forum, and almost immediately (despite the CAPTCHA thing) I got a regular trickle of spam signups. This stopped completely when I added a "Pass question"

viz: "Does Imaginatorium Shop sell: (SELECT) Watches Puzzles"?

"Watches" is the default, and the wrong answer; no signup script so far has bothered to try to work round it.

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.