Jump to content

Archived

This topic is now archived and is closed to further replies.

ultrus

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

Recommended Posts

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.  :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.