(Português) PHP Conference 2010 – Desenvolvendo Extensões PECL
Posted in development on December 2nd, 2010 by Pedro Padron – Be the first to commentSorry, this entry is only available in Português.
Sorry, this entry is only available in Português.
On the past few days I’ve been working on a PHP spamd client, and I think it is somewhat usable for now since it already implements all of the protocol commands. This is release 0.1.0, so you might expect some API changes for the next versions. Feedback is always welcome.
I tried to make this the most straight-forward as possible, abstracting some nasty things that happens under the hood, so you can do things like:
require_once 'SpamAssassin/Client.php'; $params = array( "hostname" => "localhost", "port" => "783", "user" => "ppadron", ); $sa = new SpamAssassin_Client($params); $message = file_get_contents('/path/to/message/file'); var_dump($sa->isSpam($message));
bool(true)
I’m still working on providing some good usage examples, but I’ve put (temporarily) API docs available here. In the meantime, you can browse the tests directory and learn some basic stuff.
If you want to use this library to implement a spam filter for your mail server, maybe you should consider using the spamc command line utility or the Perl library that already comes with SpamAssassin (which was my main source of inspiration).
This library is most useful when you already have stuff written in PHP and you need to do something with SpamAssassin. If you have a webmail written in PHP and would like to interact with a remote SpamAssassin server to report spam, for example.
The project is hosted @ Github, so you can:
$ git clone git://github.com/ppadron/php-spamassassin
I owe you a PEAR repo to serve this package.
If you happen to use some CPAN module that is not already available in any repo (always check EPEL), you might consider packaging it yourself. It can really be a pain if you try to do it from scratch, that’s why you should consider using cpanspec. It’s a simple tool that will generate a specfile given a CPAN package name or package file.
Sorry, this entry is only available in Português.
Compared to the old address (ppadron.w3p.com.br), the new one (ppadron.blog.br) is easier to remember and more intuitive. If you happen to follow this blog, please update your RSS reader. The old address will still work though, thanks to Apache’s RedirectMatch directive. This is the .htaccess file at ppadron.w3p.com.br:
RedirectMatch permanent (.*)$ http://ppadron.blog.br$1
This will redirect (301 Moved Permanently) anything from the old domain to the new one, preserving WordPress permalinks.