Is there a way I can use PHP to check if my email content is spam?

The idea is that before I send mail, I would like to use some code to check the content to see if it is using a spam phrase. Here is a simple code

function isSpam($text)
{
    $pattern = "/\b(actual|filter|removed|because|it|contained|obscenities)\b/i";

    if(preg_match($pattern, $text, $match))
        return true;
    else
        return false;
}

      

Question:

  • Is there a way to improve the code, like checking the runtime rather than just checking if it exists?

  • Is there any other plugin or code out there so I don't need to repeat it?

  • Bayesian Spam Filter - All About Inbox? Is this useful as an outbound email filter ?

thanks for the help

+3


source to share


2 answers


you can check any content if it contains any spam messages with a nice plugin called Akismet, it is free and used by most CMS and blogging apps like wordpress etc.

check the link http://akismet.com/



the library itself is very easy to implement, just download the library from the website and use the provided API from the documentation. and you're good to go. I found this to be very effective for me.

+2


source


If your server is equipped with SpamAssassin, you can use this API: http://ppadron.blog.br/2010/05/04/php-api-to-spamassassin-spamd-protocol/ (it may be a little outdated, but it is not would be an insurmountable task to bring it up to date).



I am sure that other anti-spam tools will have similar capabilities.

+2


source







All Articles