Jump to content


Photo

How do I detect spam in a string of text like an email message?


  • Please log in to reply
1 reply to this topic

#1 ultrus

ultrus
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts

Posted 17 October 2006 - 03:46 PM

Hello,
How do I detect potential spam in a string of text? I installed a php support ticket system for a client. Every 15 minutes a script checks the email, adds any new messages to the database, and informs the sender and company of thr new inquiry.

I want to screen the emails a bit before getting auto-replies and being added to the system. Is there anything good out there for this? I realize that I won't be able to filter out all spam, but a good knowlegebase of spammmorific content to check against would be fantastic.  :)
Twitter | Blog | Worlds to explore. Worlds to create.

#2 dwees

dwees
  • Members
  • PipPipPip
  • Advanced Member
  • 47 posts
  • LocationUnited Kingdom

Posted 17 October 2006 - 04:10 PM

You basically want to take a look in your spam filter of your current email client, and actually look at some of those messages, and write down some of the common words that are used in the messages, that are not typically used in regular messages.

Some common words to look for are 'viagra' 'cialis', etc... 

Then you perform a preg_match('/(bad|words|in|here|separated|by|or|operators)/', $text); and if the results are successful, then store the spam mail somewhere for 30 days (perhaps using a cron job to automatically delete it every 30 days) or so - in case there is some legitimate email which for some reason uses one of the bad words quoted.

You may want to do a $test = preg_replace(" ", "", $text); first to strip all of the spaces from the $text first because spammers usually try to 'trick' the spam filter by p u t t i n g some spaces in the middle of their words.  You may also want to remove all the numbers, underscores, dashes, parenthesis, etc... as well (remembering to work on a copy of the email string rather than the original), before you do any validation.

Hope this is correct, and helps.

Dave




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users