The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mail::Karmasphere::Client - Client for Karmasphere Reputation Server

SYNOPSIS

        use Mail::Karmasphere::Client qw(:all);

        my $client = new Mail::Karmasphere::Client(
                        PeerAddr        => '123.45.6.7',
                        PeerPort        => 8666,
                                );

        my $query = new Mail::Karmasphere::Query();
        $query->identity('123.45.6.7', IDT_IP4);
        $query->composite('karmasphere.email-sender');
        my $response = $client->ask($query, 6);
        print $response->as_string;

        my $id = $client->send($query);
        my $response = $client->recv($query, 12);
        my $response = $client->recv($id, 12);

        my $response = $client->query(
                Identities      => [ ... ]
                Composite       => 'karmasphere.email-sender',
                        );

DESCRIPTION

The Perl Karma Client API consists of three objects: The Query, the Response and the Client. The user constructs a Query and passes it to a Client, which returns a Response.

CONSTRUCTOR

The class method new(...) constructs a new Client object. All arguments are optional. The following parameters are recognised as arguments to new():

PeerAddr

The IP address or hostname to contact. See IO::Socket::INET. The default is 'query.karmasphere.com'.

PeerPort

The TCP or UDP to contact. See IO::Socket::INET. The default is 8666.

Proto

Either 'udp' or 'tcp'. The default is 'udp' because it is faster.

Principal

An identifier used to authenticate client connections. This may be a login or account name. The precise details will depend on the policy of the query server being used.

Credentials

The credentials used to authenticate the principal. This may be a password, or a certificate. The precise details may depend on the policy of the query server being used.

Debug

Either a true value for debugging to stderr, or a custom debug handler. The custom handler will be called with N arguments, the first of which is a string 'debug context'. The custom handler may choose to ignore messages from certain contexts.

METHODS

$response = $client->ask($query, $timeout)

Returns a Mail::Karmasphere::Response to a Mail::Karmasphere::Query. The core of this method is equivalent to

        $client->recv($client->send($query), $timeout)

The method retries up to 3 times, doubling the timeout each time. If the application requires more control over retries or backoff, it should use send() and recv() individually. $timeout is optional.

$id = $client->send($query)

Sends a Mail::Karmasphere::Query to the server, and returns the id of the query, which may be passed to recv().

$response = $client->recv($id, $timeout)

Returns a Mail::Karmasphere::Response to the query with id $id, assuming that the query has already been sent using send(). If no matching response is read before the timeout, undef is returned.

$response = $client->query(...)

A convenience method, equivalent to

        $client->ask(new Mail::Karmasphere::Query(...));

See Mail::Karmasphere::Query for more details.

EXPORTS

IDT_IP4 IDT_IP6 IDT_DOMAIN IDT_EMAIL IDT_URL

Identity type constants.

AUTHENTIC SMTP_CLIENT_IP SMTP_ENV_HELO SMTP_ENV_MAIL_FROM SMTP_ENV_RCPT_TO SMTP_HEADER_FROM_ADDRESS

Identity tags, indicating the context of an identity to the server.

FL_FACTS

A flag indicating that all facts must be returned explicitly in the Response.

BUGS

UDP retries are not yet implemented.

SEE ALSO

Mail::Karmasphere::Query, Mail::Karmasphere::Response, http://www.karmasphere.com/, Mail::SpamAssassin::Plugin::Karmasphere

COPYRIGHT

Copyright (c) 2005-2006 Shevek, Karmasphere. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.