Ulrich Kautz > Mail-Decency > Mail::Decency::Policy

Download:
Mail-Decency-0.1.6.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Mail::Decency::Policy

SYNOPSIS ^

    use Mail::Decency::Policy;
    
    # run in server mode
    my $policy = Mail::DecencyPolicy->new( {
        config => '/etc/decency/policy.yml'
    } );
    $policy->run;
    
    # run in maintenance mode
    $policy->maintenance;
    
    # print statistics
    $policy->print_stats;

DESCRIPTION ^

Policy server for Postfix or other MTAs. Could be combined with Mail::Decency::ContentFilter. Besides the existing Modules it is easy extendable for custom needs.

POSTFIX ^

To implement this in postfix, add a "check_policy_service" directive in one of the restriction classes:

    smtpd_recipient_restrictions =
        # ...
        check_policy_service inet:127.0.0.1:15000
        # ...

If you want to place this anywhere before the smtpd_recipient_restrictions, you probaly have to enable "smtpd_delay_reject" (depending on the modules you use, but to be save..)

    smtpd_delay_reject = yes

CONFIG ^

The configuration can be provided via YAML file or as HashRef.

Example:

    ---
    
    include:
        - database.yml
        - cache.yml
        - logging.yml
    
    weight_threshold: -100
    force_check_local: 1
    
    default_reject_message: "use decency"
    no_reject_detail: 0
    
    disable_prepend: 0
    forward_scoring: 1
    forward_sign_key: sign.key
    
    enable_stats: 1
    
    
    server:
        host: 127.0.0.1
        port: 15000
        instances: 3
    
    
    policy:
        - CWL: policy/cwl.yml
        - DNSBL: policy/dnsbl.yml
        - CBL: policy/cbl.yml
        - SPF: policy/spf.yml
        - Association: policy/association.yml
        - GeoWeight: policy/geo-weight.yml
        - Honeypot: policy/honeypot.yml
        - Greylist: policy/greylist.yml
        - Throttle: policy/throttle.yml

DATABASE

SQL CREATE statements (SQLite) for the stats role:

    -- TABLE: stats_contentfilter_performance (SQLITE):
    CREATE TABLE STATS_CONTENTFILTER_PERFORMANCE (calls varchar(10), runtime real, period varchar(10), type varchar(32), start integer, module varchar(32), id INTEGER PRIMARY KEY);
    
    CREATE UNIQUE INDEX STATS_CONTENTFILTER_PERFORMANCE_MODULE_PERIOD_START_TYPE ON STATS_CONTENTFILTER_PERFORMANCE (module, period, start, type);
    
    -- TABLE: stats_contentfilter_response (SQLITE):
    CREATE TABLE STATS_CONTENTFILTER_RESPONSE (period varchar(10), type varchar(32), start integer, module varchar(32), id INTEGER PRIMARY KEY);
    
    CREATE UNIQUE INDEX STATS_CONTENTFILTER_RESPONSE_MODULE_PERIOD_START_TYPE ON STATS_CONTENTFILTER_RESPONSE (module, period, start, type);

CLASS ATTRIBUTES ^

See Mail::Decency::Policy::Core

weight_threshold : Int

Threshold of spam score before reject ( actual score <= threeshold == spam )

session_data : Mail::Decency::Core::SessionItem::Policy

Instance of Mail::Decency::Core::SessionItem::Policy

pass_localhost : Bool

Wheter passing everything from localhost or not

Default: 1

default_reject_message : Str

Default reject message string (after the SMTP REJECT command .. "REJECT message")

Default: use decency

no_reject_detail : Bool

Wheter pass detailed information of why a particular REJECT has been thrown to the sender or not (not=always the default message)/

Default: 0

forward_scoring : Bool

Wheter forward scoring informations after policies or not

Default: 0

disable_prepend : Bool

Wheter disabling the prepend of instance information fully (implies forward_scoring=0)

Default: 0

forward_sign_key : Str

Path to a file containing a private key for signing forwarded

forward_sign_key_priv : Crypt::OpenSSL::RSA

Instance of Crypt::OpenSSL::RSA representing the forward sign key

METHODS ^

init

Loads policy modules, inits caches, inits databases ..

get_handlers

Returns subref to handlers, called by Mail::Decency::Core::POEForking::Postfix

    # all handlers
    my $handlers_ref = $policy->get_handlers();
    
    # only the awl handler
    my $handlers_ref = $policy->get_handlers( qw/ AWL / );

start

Starts all POE servers without calling the POE::Kernel->run

run

Start and run the server via POE::Kernel->run

session_init $attributes_ref

Called at start of every handle cycle. Inits all handle/session-variables

session_cleanup

Clears all info from session cache, returns final response

add_spam_score $module, $weight, $details, $reject_message

Add weight and filter info to current instance.

Throws _FinalStateException if weighting indicates spam

go_final_state $module, $state, $message

Throws Mail::Decency::Core::Exception exception if state is not DUNNO.

Adds message to list of response messages

add_response_message $message

Add message (not details) to response

SEE ALSO ^

AUTHOR ^

Ulrich Kautz <uk@fortrabbit.de>

COPYRIGHT ^

Copyright (c) 2010 the "AUTHOR" as listed above

LICENCSE ^

This library is free software and may be distributed under the same terms as perl itself.

syntax highlighting: