Jump to content

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


ultrus

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.  :)
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.