Php: Check if email content is spam

时光怂恿深爱的人放手 提交于 2019-12-10 21:26:25

问题


I'm creating a newsletter feature that will allow users to send emails. Since there are malicious people out there who would want to send spam, I'm wanting to be able to check and see if the message created is spam or not.

I've looked at a couple different methods like trying spam assassin but you need the full email which I won't have until later. Or you need to install some other utilities like spamd, but I'm looking for a php class that does this for me anyone know of anything? Or am i stuck having to install some command line app that does this?

Ideally something easy like this:

$spamChecker = new SpamChecker();
$message =  "Free Credit report, blah blah, I am spam! Detect me if you dare!";
if($spamChecker->isSpam($message)) {
    echo "You are a spammer!";
} else {
    echo "you are my friend";
}

回答1:


I would have the following line of protection:

1. authentication.

  • First authenticate user using something like for example lightopenid. When you use google as openid provider for instance then you have a very good chance that the users isn't a spammer, because they take measures against spammers.

2. Akismet/Sblam

  • Like glenn pointed out you can use akismet which is free for personal sites. Or you could try sblam which is free to use.

3. Captcha

  • You could back the mailinglist up by captcha for even further protection.

4. authorization.

  • Ban openid urls which spam.



回答2:


Quite possibly the best service for filtering spam is Akismet. Akismet is quite widely used. It is included by default with Wordpress. I personally use it for my own site if that lends any credibility to Akismet. They also have many pre-made plugins/scripts for various server-side languages.




回答3:


spam assassin but you need the full email which I won't have until later

Nonsense - there's nothing to stop you using spamassassin to process arbitary data - its just that nobody would bother documenting how to do this. You don't even have to mess about with dummy headers - just pipe it through spamc and check the return code.

However you're just going to be a target for spammers unless you're very careful about establishing the credentials of your users - and that at least means checking for a valid email address - and if they have a valid email address, why would they use your service?



来源:https://stackoverflow.com/questions/4702397/php-check-if-email-content-is-spam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!