PHP Email Script Giving me lots of spam.

Discussion in 'PHP' started by rcavezza, May 5, 2009.

  1. #1
    I have a simple contact me script that sends me personal emails about people wanting more information about my services.

    However, I have been getting lots of random spam. Can someone hook me up with a script that will help stop the spam? Below is one of the many sample spam messages I get each night. I get around 5-15 per day and less than 1 actual email per week that is legitimate. Any suggestions would help. I used to have a javascript applet that would return an error message if all fields weren't filled in, but that didn't help.

    Any help would be appreciated.

    Robert M. Cavezza

    Here's a sample spam message I have been getting from my script.

    ======================================================
    ======================================================
    ======================================================

    Array
    (
    [name] => victorianessaff
    [emaill] => viepaypezek112@gmail.com
    [state] => Namibia
    [class] => 2009
    [comments] => nice tablets quality <a href=http://airsoftgunhelp.com/airsoft/member.php?u=28132>buy xanax without prescription</a>
    pharmacy technician <a href=http://forums.trumba.com/index.php?showuser=2848>buy valium online</a>
    comment avoir ventre plat <a href=http://www.myiwc.com/forums/member.php?u=3357>zoloft online pharmacy</a>
    health wellness program <a href=http://forums.epicgames.com/member.php?u=1363354>buy soma online</a>
    healthy recipe <a href=http://boinc.umiacs.umd.edu/view_profile.php?userid=20905>purchase ativan</a>
     
    rcavezza, May 5, 2009 IP
  2. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #2
    just use a captcha to prevent bots from spamming your form

    try googling recaptcha :)

    cheers
     
    creativeGenius, May 5, 2009 IP
  3. rcavezza

    rcavezza Peon

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Can you name any captcha's that are easy to understand (I sometimes have to reenter the captcha 3 times at certain webpages) that are free.
     
    rcavezza, May 5, 2009 IP
  4. srobona

    srobona Active Member

    Messages:
    577
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    88
    #4
    You can use captcha ZDR, it is free and very easy to set in your site.
     
    srobona, May 5, 2009 IP
  5. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #5
    captcha is the only option to this. You will get the script for generating captcha. It used GD library. Every contact us page or comment page where login is not required should be protected with captcha to prevent the email flooding by spamming bots.
     
    MayurGondaliya, May 5, 2009 IP
  6. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #6
    It is not the only option, and not the most effective as it can be easily cracked.

    Personally, I use "question asking" where you ask the user a question and have an answer before hand. Something like 1 + 365, what color is an orange, etc. I found this method 100% fool proof.

    Peace,
     
    Barti1987, May 5, 2009 IP
  7. rcavezza

    rcavezza Peon

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I installed the captcha zdr yesterday and still received 5 more spam emails last night.

    That captcha is "question asking" such as azizny's post.

    Should I post my entire php file so you guys understand the code I have thus far?
     
    rcavezza, May 9, 2009 IP
  8. alfa_375

    alfa_375 Active Member

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #8
    I think this is good idea, then you will get an appropriate help.
     
    alfa_375, May 9, 2009 IP
  9. Steve136

    Steve136 Peon

    Messages:
    240
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi,

    I've found picture selecting to be the best form of human verification,

    for example, you ask the following question?

    Which one of these is a balloon? - Then show three/four small photos containing different objects, there is no way for automated spam bots to recognize from a photo which object is the correct one.

    It's actually very simple to create (if you know the basics of PHP)

    1. Before anything else generate a random number based on how many images you have, store this in a session variable.

    2. Show the question (from array/txt/database) and three or four small photo's giving them option boxes at the side to go with it, with the names of 1, 2, 3, 4.

    3. On the final page, after submission - Use the random number in the session variable as an index to re-select the question (from either array/txt/database) and check the entered value against the correct one.

    It's a good idea to make your own captcha verification or modify an existing one, as this will give your website some uniqueness so that the spam bots will not have any routines recorded to get around your captcha system.

    Done a quick search on google and found an example of what I was talking about, here - Although this one looks ugly and is way too big for a normal contact form.

    Hope it helps a little.

    Regards,

    Steve
     
    Steve136, May 9, 2009 IP
  10. fourfingers

    fourfingers Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    A simple fix would likely be to just check the referral as most spammers don't bother sending it. This would probably fix 98% of your issues
     
    fourfingers, May 13, 2009 IP
  11. -[z]-

    -[z]- Active Member

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #11
    Block referrers coming from anywhere else other your site.

    
    $domain = ("http://yourdomain.com");
    $ref = getenv ('HTTP_REFERER');
    
    if(eregi($ref,$domain)) {
    //Send email here.
    } else {
    exit(); //Stops the entire script.
    }
    
    PHP:
    And use a captcha as well to maximize protection.
     
    -[z]-, May 14, 2009 IP
    chandan123 likes this.
  12. X-N2O

    X-N2O Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    You can also set a limit to each IP. EX: 5 minutes between each email.
     
    X-N2O, May 14, 2009 IP
  13. fex

    fex Peon

    Messages:
    89
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Mmmh,, I've got a recaptcha on my website and ever since spam stopped completely. Images are "easy to understand" and a refresh button is included. Easy to install as well.. http://recaptcha.net/
     
    fex, May 14, 2009 IP
  14. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #14
    And, if you'd paid attention to the latest 4chan / Anonymous Time Magazine hack, you'd know that reCaptcha isn't even remotely safe - although it would take some dedication to beat it.
     
    PoPSiCLe, May 14, 2009 IP
  15. chandan123

    chandan123 Prominent Member

    Messages:
    11,586
    Likes Received:
    578
    Best Answers:
    0
    Trophy Points:
    360
    #15
    -[z]- method is best one i am using that from long time :p checking referrer is the best method to avoid bots or any automated scripts
     
    chandan123, May 14, 2009 IP
  16. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Unless you get a bot that spoofs the referrer which is easily done in curl. then its useless
     
    atlantaazfinest, May 14, 2009 IP
  17. -[z]-

    -[z]- Active Member

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #17
    You can spoof the referrer without cURL and most bots send referrers to try and get past this check, thats why I said use both methods.

    And as for reCaptcha I personally don't trust them... I use a free captcha script that I modified to keep the spam at bay.

    To be perfectly honest, some spammers will work hard to get the stuff posted/submitted even logic questions can be beaten with help of a Google and Yahoo! Answers scraper and the other problem is that it easy to make a scraper but at least the logic formula will be a challenge to crack.

    But overall a captcha and referrer check should protect you from most spam and the spam that gets through is just a fact of life that...
     
    -[z]-, May 15, 2009 IP