I think I should look for another hobby as having bad ideas and trying them out can be quite time intensive. But here is an idea I put to code lately. What is the best spam killer for free? Spamassassin. Can’t we abuse it for spam checking on webpages? Let’s find out.
Spamassassin is usually doing its job as the spamd process, talking to the mail server via sockets or a TCP Connection. What we need to do is creating a minimalistic RFC822 message with the line endings used from MSDOS Times – CrLf.
As PHP is able to talk to sockets using the socket_create() function, we can pass this messages on to the spamd, trying to get its response. The message header of course has to be faked, as we are not receiving a mail message. But this should not be a problem as we got all required data. Forgive me the mix of example data and php functions, you should be able to get the idea although:
From $comment_email ”
gmdate(“D M d H:i:s Y”)
Received: from gethostbyaddr($user_ip) $user_ip by $_SERVER[“HTTP_HOST”] via $sitename; date(“r”)
From: $comment_name <$comment_email>
This way SpamAssassin is able to deal with our comment as it would be a mail entering our mail system. So we would be able to see why a message is spam, according to the SpamAssassin rule sets. A queue implementation would be needed to ensure proper handling if there is big spam traffic.
Ideas? Comments? Complains? Feel free to drop me a line.