Server IP : 103.119.228.120 / Your IP : 3.149.214.223 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/share/man/man3/ |
Upload File : |
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mail::SpamAssassin::Plugin 3" .TH Mail::SpamAssassin::Plugin 3 "2015-04-29" "perl v5.16.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mail::SpamAssassin::Plugin \- SpamAssassin plugin base class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .SS "SpamAssassin configuration:" .IX Subsection "SpamAssassin configuration:" .Vb 1 \& loadplugin MyPlugin /path/to/myplugin.pm .Ve .SS "Perl code:" .IX Subsection "Perl code:" .Vb 1 \& package MyPlugin; \& \& use Mail::SpamAssassin::Plugin; \& our @ISA = qw(Mail::SpamAssassin::Plugin); \& \& sub new { \& my ($class, $mailsa) = @_; \& \& # the usual perlobj boilerplate to create a subclass object \& $class = ref($class) || $class; \& my $self = $class\->SUPER::new($mailsa); \& bless ($self, $class); \& \& # then register an eval rule, if desired... \& $self\->register_eval_rule ("check_for_foo"); \& \& # and return the new plugin object \& return $self; \& } \& \& ...methods... \& \& 1; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is the base class for SpamAssassin plugins; all plugins must be objects that implement this class. .PP This class provides no-op stub methods for all the callbacks that a plugin can receive. It is expected that your plugin will override one or more of these stubs to perform its actions. .PP SpamAssassin implements a plugin chain; each callback event is passed to each of the registered plugin objects in turn. Any plugin can call \&\f(CW\*(C`$self\->inhibit_further_callbacks()\*(C'\fR to block delivery of that event to later plugins in the chain. This is useful if the plugin has handled the event, and there will be no need for later plugins to handle it as well. .PP If you're looking to write a simple eval rule, skip straight to \&\f(CW\*(C`register_eval_rule()\*(C'\fR, below. .SH "INTERFACE" .IX Header "INTERFACE" In all the plugin APIs below, \f(CW\*(C`options\*(C'\fR refers to a reference to a hash containing name-value pairs. This is used to ensure future-compatibility, in that we can add new options in future without affecting objects built to an earlier version of the \s-1API.\s0 .PP For example, here would be how to print out the \f(CW\*(C`line\*(C'\fR item in a \&\f(CW\*(C`parse_config()\*(C'\fR method: .PP .Vb 4 \& sub parse_config { \& my ($self, $opts) = @_; \& print "MyPlugin: parse_config got ".$opts\->{line}."\en"; \& } .Ve .SH "METHODS" .IX Header "METHODS" The following methods can be overridden by subclasses to handle events. .ie n .IP "$plugin = MyPluginClass\->new ($mailsaobject)" 4 .el .IP "\f(CW$plugin\fR = MyPluginClass\->new ($mailsaobject)" 4 .IX Item "$plugin = MyPluginClass->new ($mailsaobject)" Constructor. Plugins that need to register themselves will need to define their own; the default super-class constructor will work fine for plugins that just override a method. .Sp Note that subclasses must provide the \f(CW$mailsaobject\fR to the superclass constructor, like so: .Sp .Vb 1 \& my $self = $class\->SUPER::new($mailsaobject); .Ve .Sp Lifecycle note: plugins that will need to store per-scan state should not store that on the Plugin object; instead this should be stored on the PerMsgStatus object, see \f(CW\*(C`check_start()\*(C'\fR below. It is also likewise recommended that configuration settings be stored on the Conf object; see \f(CW\*(C`parse_config()\*(C'\fR. .ie n .IP "$plugin\->parse_config ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->parse_config ( { options ... } )" 4 .IX Item "$plugin->parse_config ( { options ... } )" Parse a configuration line that hasn't already been handled. \f(CW\*(C`options\*(C'\fR is a reference to a hash containing these options: .RS 4 .IP "line" 4 .IX Item "line" The line of configuration text to parse. This has leading and trailing whitespace, and comments, removed. .IP "key" 4 .IX Item "key" The configuration key; ie. the first \*(L"word\*(R" on the line. .IP "value" 4 .IX Item "value" The configuration value; everything after the first \*(L"word\*(R" and any whitespace after that. .IP "conf" 4 .IX Item "conf" The \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object on which the configuration data should be stored. .IP "user_config" 4 .IX Item "user_config" A boolean: \f(CW1\fR if reading a user's configuration, \f(CW0\fR if reading the system-wide configuration files. .RE .RS 4 .Sp If the configuration line was a setting that is handled by this plugin, the method implementation should call \f(CW\*(C`$self\->inhibit_further_callbacks()\*(C'\fR. .Sp If the setting is not handled by this plugin, the method should return \f(CW0\fR so that a later plugin may handle it, or so that SpamAssassin can output a warning message to the user if no plugin understands it. .Sp Lifecycle note: it is suggested that configuration be stored on the \&\f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object in use, instead of the plugin object itself. That can be found as \f(CW\*(C`$plugin\->{main}\->{conf}\*(C'\fR, or as \*(L"conf\*(R" in the \&\f(CW$options\fR hash reference above. By storing it on \f(CW\*(C`conf\*(C'\fR, this allows per-user and system-wide configuration precedence to be dealt with correctly. .RE .ie n .IP "$plugin\->finish_parsing_start ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->finish_parsing_start ( { options ... } )" 4 .IX Item "$plugin->finish_parsing_start ( { options ... } )" Signals that the system-wide configuration has been completely read, but internal data structures are not yet created. It is possible to use this hook to dynamically change the configuration already read in or add new config options. .Sp \&\f(CW\*(C`options\*(C'\fR is a reference to a hash containing these options: .RS 4 .IP "conf" 4 .IX Item "conf" The \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object on which the configuration data should be stored. .RE .RS 4 .Sp Note: there are no guarantees that the internal data structures of SpamAssassin will not change from release to release. In particular to this plugin hook, if you modify the rules data structures in a third-party plugin, all bets are off until such time that an \s-1API\s0 is present for modifying that configuration data. .RE .ie n .IP "$plugin\->finish_parsing_end ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->finish_parsing_end ( { options ... } )" 4 .IX Item "$plugin->finish_parsing_end ( { options ... } )" Signals that the system-wide configuration parsing has just finished, and SpamAssassin is nearly ready to check messages. .Sp \&\f(CW\*(C`options\*(C'\fR is a reference to a hash containing these options: .RS 4 .IP "conf" 4 .IX Item "conf" The \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object on which the configuration data should be stored. .RE .RS 4 .Sp Note: there are no guarantees that the internal data structures of SpamAssassin will not change from release to release. In particular to this plugin hook, if you modify the rules data structures in a third-party plugin, all bets are off until such time that an \s-1API\s0 is present for modifying that configuration data. .RE .ie n .IP "$plugin\->user_conf_parsing_start ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->user_conf_parsing_start ( { options ... } )" 4 .IX Item "$plugin->user_conf_parsing_start ( { options ... } )" Signals that the per-user configuration has been completely read, but not converted to internal data structures. It is possible to use this hook to dynamically change the configuration already read in or add new config options. .Sp If \f(CW\*(C`allow_user_rules\*(C'\fR is enabled in the configuration, it is possible that additional rules have been added since the \f(CW\*(C`finish_parsing_start\*(C'\fR plugin hook invocation was called. .RS 4 .IP "conf" 4 .IX Item "conf" The \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object on which the configuration data should be stored. .RE .RS 4 .Sp Note: there are no guarantees that the internal data structures of SpamAssassin will not change from release to release. In particular to this plugin hook, if you modify the rules data structures in a third-party plugin, all bets are off until such time that an \s-1API\s0 is present for modifying that configuration data. .RE .ie n .IP "$plugin\->user_conf_parsing_end ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->user_conf_parsing_end ( { options ... } )" 4 .IX Item "$plugin->user_conf_parsing_end ( { options ... } )" Signals that the per-user configuration parsing has just finished, and SpamAssassin is nearly ready to check messages. If \f(CW\*(C`allow_user_rules\*(C'\fR is enabled in the configuration, it is possible that additional rules have been added since the \f(CW\*(C`finish_parsing_end\*(C'\fR plugin hook invocation was called. .Sp \&\f(CW\*(C`options\*(C'\fR is a reference to a hash containing these options: .RS 4 .IP "conf" 4 .IX Item "conf" The \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object on which the configuration data should be stored. .RE .RS 4 .Sp Note: there are no guarantees that the internal data structures of SpamAssassin will not change from release to release. In particular to this plugin hook, if you modify the rules data structures in a third-party plugin, all bets are off until such time that an \s-1API\s0 is present for modifying that configuration data. .RE .ie n .IP "$plugin\->signal_user_changed ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->signal_user_changed ( { options ... } )" 4 .IX Item "$plugin->signal_user_changed ( { options ... } )" Signals that the current user has changed for a new one. .RS 4 .IP "username" 4 .IX Item "username" The new user's username. .IP "user_dir" 4 .IX Item "user_dir" The new user's home directory. (equivalent to \f(CW\*(C`~\*(C'\fR.) .IP "userstate_dir" 4 .IX Item "userstate_dir" The new user's storage directory. (equivalent to \f(CW\*(C`~/.spamassassin\*(C'\fR.) .RE .RS 4 .RE .ie n .IP "$plugin\->services_authorized_for_username ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->services_authorized_for_username ( { options ... } )" 4 .IX Item "$plugin->services_authorized_for_username ( { options ... } )" Validates that a given username is authorized to use certain services. .Sp In order to authorize a user, the plugin should first check that it can handle any of the services passed into the method and then set the value for each allowed service to true (or any non-negative value). .Sp The current supported services are: bayessql .RS 4 .IP "username" 4 .IX Item "username" A username .IP "services" 4 .IX Item "services" Reference to a hash containing the services you want to check. .Sp { .Sp .Vb 1 \& \*(Aqbayessql\*(Aq => 0 .Ve .Sp } .IP "conf" 4 .IX Item "conf" The \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object on which the configuration data should be stored. .RE .RS 4 .RE .ie n .IP "$plugin\->compile_now_start ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->compile_now_start ( { options ... } )" 4 .IX Item "$plugin->compile_now_start ( { options ... } )" This is called at the beginning of \fIMail::SpamAssassin::compile_now()\fR so plugins can do any necessary initialization for multi-process SpamAssassin (such as spamd or mass-check \-j). .RS 4 .IP "use_user_prefs" 4 .IX Item "use_user_prefs" The value of \f(CW$use_user_prefs\fR option in \fIcompile_now()\fR. .IP "keep_userstate" 4 .IX Item "keep_userstate" The value of \f(CW$keep_userstate\fR option in \fIcompile_now()\fR. .RE .RS 4 .RE .ie n .IP "$plugin\->compile_now_finish ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->compile_now_finish ( { options ... } )" 4 .IX Item "$plugin->compile_now_finish ( { options ... } )" This is called at the end of \fIMail::SpamAssassin::compile_now()\fR so plugins can do any necessary initialization for multi-process SpamAssassin (such as spamd or mass-check \-j). .RS 4 .IP "use_user_prefs" 4 .IX Item "use_user_prefs" The value of \f(CW$use_user_prefs\fR option in \fIcompile_now()\fR. .IP "keep_userstate" 4 .IX Item "keep_userstate" The value of \f(CW$keep_userstate\fR option in \fIcompile_now()\fR. .RE .RS 4 .RE .ie n .IP "$plugin\->check_start ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->check_start ( { options ... } )" 4 .IX Item "$plugin->check_start ( { options ... } )" Signals that a message check operation is starting. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .Sp Lifecycle note: it is recommended that rules that need to track test state on a per-scan basis should store that state on this object, not on the plugin object itself, since the plugin object will be shared between all active scanners. .Sp The message being scanned is accessible through the \&\f(CW\*(C`$permsgstatus\->get_message()\*(C'\fR \s-1API\s0; there are a number of other public APIs on that object, too. See \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR perldoc. .RE .RS 4 .RE .ie n .IP "$plugin\->check_main ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->check_main ( { options ... } )" 4 .IX Item "$plugin->check_main ( { options ... } )" Signals that a message should be checked. Note that implementations of this hook should return \f(CW1\fR. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->check_tick ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->check_tick ( { options ... } )" 4 .IX Item "$plugin->check_tick ( { options ... } )" Called periodically during a message check operation. A callback set for this method is a good place to run through an event loop dealing with network events triggered in a \f(CW\*(C`parse_metadata\*(C'\fR method, for example. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->check_post_dnsbl ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->check_post_dnsbl ( { options ... } )" 4 .IX Item "$plugin->check_post_dnsbl ( { options ... } )" Called after the \s-1DNSBL\s0 results have been harvested. This is a good place to harvest your own asynchronously-started network lookups. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->check_post_learn ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->check_post_learn ( { options ... } )" 4 .IX Item "$plugin->check_post_learn ( { options ... } )" Called after auto-learning may (or may not) have taken place. If you wish to perform additional learning, whether or not auto-learning happens, this is the place to do it. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->check_end ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->check_end ( { options ... } )" 4 .IX Item "$plugin->check_end ( { options ... } )" Signals that a message check operation has just finished, and the results are about to be returned to the caller. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. The current score, names of rules that hit, etc. can be retrieved using the public APIs on this object. .RE .RS 4 .RE .ie n .IP "$plugin\->finish_tests ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->finish_tests ( { options ... } )" 4 .IX Item "$plugin->finish_tests ( { options ... } )" Called via \f(CW\*(C`Mail::SpamAssassin::finish\*(C'\fR. This should clear up any tests that a plugin has added to the namespace. .Sp In certain circumstances, plugins may find it useful to compile perl functions from the ruleset, on the fly. It is important to remove these once the \f(CW\*(C`Mail::SpamAssassin\*(C'\fR object is deleted, however, and this \s-1API\s0 allows this. .Sp Each plugin is responsible for its own generated perl functions. .RS 4 .IP "conf" 4 .IX Item "conf" The \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object on which the configuration data should be stored. .RE .RS 4 .Sp See also the \f(CW\*(C`register_generated_rule_method\*(C'\fR helper \s-1API,\s0 below. .RE .ie n .IP "$plugin\->extract_metadata ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->extract_metadata ( { options ... } )" 4 .IX Item "$plugin->extract_metadata ( { options ... } )" Signals that a message is being mined for metadata. Some plugins may wish to add their own metadata as well. .RS 4 .IP "msg" 4 .IX Item "msg" The \f(CW\*(C`Mail::SpamAssassin::Message\*(C'\fR object for this message. .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->parsed_metadata ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->parsed_metadata ( { options ... } )" 4 .IX Item "$plugin->parsed_metadata ( { options ... } )" Signals that a message's metadata has been parsed, and can now be accessed by the plugin. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->start_rules ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->start_rules ( { options ... } )" 4 .IX Item "$plugin->start_rules ( { options ... } )" Called before testing a set of rules of a given type and priority. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .IP "ruletype" 4 .IX Item "ruletype" The type of the rules about to be performed. .IP "priority" 4 .IX Item "priority" The priority level of the rules about to be performed. .RE .RS 4 .RE .ie n .IP "$plugin\->hit_rule ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->hit_rule ( { options ... } )" 4 .IX Item "$plugin->hit_rule ( { options ... } )" Called when a rule fires. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .IP "ruletype" 4 .IX Item "ruletype" The type of the rule that fired. .IP "rulename" 4 .IX Item "rulename" The name of the rule that fired. .IP "score" 4 .IX Item "score" The rule's score in the active scoreset. .RE .RS 4 .RE .ie n .IP "$plugin\->ran_rule ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->ran_rule ( { options ... } )" 4 .IX Item "$plugin->ran_rule ( { options ... } )" Called after a rule has been tested, whether or not it fired. When the rule fires, the hit_rule callback is always called before this. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .IP "ruletype" 4 .IX Item "ruletype" The type of the rule that was tested. .IP "rulename" 4 .IX Item "rulename" The name of the rule that was tested. .RE .RS 4 .RE .ie n .IP "$plugin\->autolearn_discriminator ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->autolearn_discriminator ( { options ... } )" 4 .IX Item "$plugin->autolearn_discriminator ( { options ... } )" Control whether a just-scanned message should be learned as either spam or ham. This method should return one of \f(CW1\fR to learn the message as spam, \f(CW0\fR to learn as ham, or \f(CW\*(C`undef\*(C'\fR to not learn from the message at all. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->autolearn ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->autolearn ( { options ... } )" 4 .IX Item "$plugin->autolearn ( { options ... } )" Signals that a message is about to be auto-learned as either ham or spam. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .IP "isspam" 4 .IX Item "isspam" \&\f(CW1\fR if the message is spam, \f(CW0\fR if ham. .RE .RS 4 .RE .ie n .IP "$plugin\->per_msg_finish ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->per_msg_finish ( { options ... } )" 4 .IX Item "$plugin->per_msg_finish ( { options ... } )" Signals that a \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR object is being destroyed, and any per-scan context held on that object by this plugin should be destroyed as well. .Sp Normally, any member variables on the \f(CW\*(C`PerMsgStatus\*(C'\fR object will be cleaned up automatically \*(-- but if your plugin has made a circular reference on that object, this is the place to break them so that garbage collection can operate correctly. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->have_shortcircuited ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->have_shortcircuited ( { options ... } )" 4 .IX Item "$plugin->have_shortcircuited ( { options ... } )" Has the current scan operation 'short\-circuited'? In other words, can further scanning be skipped, since the message is already definitively classified as either spam or ham? .Sp Plugins should return \f(CW0\fR to indicate that scanning should continue, or \f(CW1\fR to indicate that short-circuiting has taken effect. .RS 4 .IP "permsgstatus" 4 .IX Item "permsgstatus" The \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR context object for this scan. .RE .RS 4 .RE .ie n .IP "$plugin\->bayes_learn ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->bayes_learn ( { options ... } )" 4 .IX Item "$plugin->bayes_learn ( { options ... } )" Called at the end of a bayes learn operation. .Sp This phase is the best place to map the raw (original) token value to the \s-1SHA1\s0 hashed value. .RS 4 .IP "toksref" 4 .IX Item "toksref" Reference to hash returned by call to tokenize. The hash takes the format of: .Sp .Vb 4 \& { \& \*(AqSHA1 Hash Value\*(Aq => \*(Aqraw (original) value\*(Aq, \& ... \& } .Ve .Sp \&\s-1NOTE:\s0 This data structure has changed since it was originally introduced in version 3.0.0. The values are no longer perl anonymous hashes, they are a single string containing the raw token value. You can test for backward compatibility by checking to see if the value for a key is a reference to a perl \s-1HASH,\s0 for instance: .Sp if (ref($toksref\->{$sometokenkey}) eq '\s-1HASH\s0') {... .Sp If it is, then you are using the old interface, otherwise you are using the current interface. .IP "isspam" 4 .IX Item "isspam" Boolean value stating what flavor of message the tokens represent, if true then message was specified as spam, false is nonspam. Note, when function is scan then isspam value is not valid. .IP "msgid" 4 .IX Item "msgid" Generated message id of the message just learned. .IP "msgatime" 4 .IX Item "msgatime" Received date of the current message or current time if received date could not be determined. In addition, if the receive date is more than 24 hrs into the future it will be reset to current datetime. .RE .RS 4 .RE .ie n .IP "$plugin\->bayes_forget ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->bayes_forget ( { options ... } )" 4 .IX Item "$plugin->bayes_forget ( { options ... } )" Called at the end of a bayes forget operation. .RS 4 .IP "toksref" 4 .IX Item "toksref" Reference to hash returned by call to tokenize. See bayes_learn documentation for additional information on the format. .IP "isspam" 4 .IX Item "isspam" Boolean value stating what flavor of message the tokens represent, if true then message was specified as spam, false is nonspam. Note, when function is scan then isspam value is not valid. .IP "msgid" 4 .IX Item "msgid" Generated message id of the message just forgotten. .RE .RS 4 .RE .ie n .IP "$plugin\->bayes_scan ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->bayes_scan ( { options ... } )" 4 .IX Item "$plugin->bayes_scan ( { options ... } )" Called at the end of a bayes scan operation. \s-1NOTE:\s0 Will not be called in case of error or if the message is otherwise skipped. .RS 4 .IP "toksref" 4 .IX Item "toksref" Reference to hash returned by call to tokenize. See bayes_learn documentation for additional information on the format. .IP "probsref" 4 .IX Item "probsref" Reference to hash of calculated probabilities for tokens found in the database. .Sp .Vb 8 \& { \& \*(AqSHA1 Hash Value\*(Aq => { \& \*(Aqprob\*(Aq => \*(Aqcalculated probability\*(Aq, \& \*(Aqspam_count\*(Aq => \*(AqTotal number of spam msgs w/ token\*(Aq, \& \*(Aqham_count\*(Aq => \*(AqTotal number of ham msgs w/ token\*(Aq, \& \*(Aqatime\*(Aq => \*(AqAtime value for token in database\*(Aq \& } \& } .Ve .IP "score" 4 .IX Item "score" Score calculated for this particular message. .IP "msgatime" 4 .IX Item "msgatime" Calculated atime of the message just learned, note it may have been adjusted if it was determined to be too far into the future. .IP "significant_tokens" 4 .IX Item "significant_tokens" Array ref of the tokens found to be significant in determining the score for this message. .RE .RS 4 .RE .ie n .IP "$plugin\->plugin_report ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->plugin_report ( { options ... } )" 4 .IX Item "$plugin->plugin_report ( { options ... } )" Called if the message is to be reported as spam. If the reporting system is available, the variable \f(CW\*(C`$options\->{report}\->report_available}\*(C'\fR should be set to \f(CW1\fR; if the reporting system successfully reported the message, the variable \f(CW\*(C`$options\->{report}\->report_return}\*(C'\fR should be set to \f(CW1\fR. .RS 4 .IP "report" 4 .IX Item "report" Reference to the Reporter object (\f(CW\*(C`$options\->{report}\*(C'\fR in the paragraph above.) .IP "text" 4 .IX Item "text" Reference to a markup removed copy of the message in scalar string format. .IP "msg" 4 .IX Item "msg" Reference to the original message object. .RE .RS 4 .RE .ie n .IP "$plugin\->plugin_revoke ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->plugin_revoke ( { options ... } )" 4 .IX Item "$plugin->plugin_revoke ( { options ... } )" Called if the message is to be reported as ham (revokes a spam report). If the reporting system is available, the variable \&\f(CW\*(C`$options\->{revoke}\->revoke_available}\*(C'\fR should be set to \f(CW1\fR; if the reporting system successfully revoked the message, the variable \&\f(CW\*(C`$options\->{revoke}\->revoke_return}\*(C'\fR should be set to \f(CW1\fR. .RS 4 .IP "revoke" 4 .IX Item "revoke" Reference to the Reporter object (\f(CW\*(C`$options\->{revoke}\*(C'\fR in the paragraph above.) .IP "text" 4 .IX Item "text" Reference to a markup removed copy of the message in scalar string format. .IP "msg" 4 .IX Item "msg" Reference to the original message object. .RE .RS 4 .RE .ie n .IP "$plugin\->whitelist_address( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->whitelist_address( { options ... } )" 4 .IX Item "$plugin->whitelist_address( { options ... } )" Called when a request is made to add an address to a persistent address list. .RS 4 .IP "address" 4 .IX Item "address" Address you wish to add. .IP "cli_p" 4 .IX Item "cli_p" Indicate if the call is being made from a command line interface. .RE .RS 4 .RE .ie n .IP "$plugin\->blacklist_address( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->blacklist_address( { options ... } )" 4 .IX Item "$plugin->blacklist_address( { options ... } )" Called when a request is made to add an address to a persistent address list. .RS 4 .IP "address" 4 .IX Item "address" Address you wish to add. .IP "cli_p" 4 .IX Item "cli_p" Indicate if the call is being made from a command line interface. .RE .RS 4 .RE .ie n .IP "$plugin\->remove_address( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->remove_address( { options ... } )" 4 .IX Item "$plugin->remove_address( { options ... } )" Called when a request is made to remove an address to a persistent address list. .RS 4 .IP "address" 4 .IX Item "address" Address you wish to remove. .IP "cli_p" 4 .IX Item "cli_p" Indicate if the call is being made from a command line interface. .RE .RS 4 .RE .ie n .IP "$plugin\->spamd_child_init ()" 4 .el .IP "\f(CW$plugin\fR\->spamd_child_init ()" 4 .IX Item "$plugin->spamd_child_init ()" Called in each new child process when it starts up under spamd. .ie n .IP "$plugin\->log_scan_result ( { options ... } )" 4 .el .IP "\f(CW$plugin\fR\->log_scan_result ( { options ... } )" 4 .IX Item "$plugin->log_scan_result ( { options ... } )" Called when spamd has completed scanning a message. Currently, only spamd calls this \s-1API.\s0 .RS 4 .IP "result" 4 .IX Item "result" The \f(CW\*(Aqresult: ...\*(Aq\fR line for this scan. Format is as described at \fBhttp://wiki.apache.org/spamassassin/SpamdSyslogFormat\fR. .RE .RS 4 .RE .ie n .IP "$plugin\->spamd_child_post_connection_close ()" 4 .el .IP "\f(CW$plugin\fR\->spamd_child_post_connection_close ()" 4 .IX Item "$plugin->spamd_child_post_connection_close ()" Called when child returns from handling a connection. .Sp If there was an accept failure, the child will die and this code will not be called. .ie n .IP "$plugin\->finish ()" 4 .el .IP "\f(CW$plugin\fR\->finish ()" 4 .IX Item "$plugin->finish ()" Called when the \f(CW\*(C`Mail::SpamAssassin\*(C'\fR object is destroyed. .ie n .IP "$plugin\->learner_new ()" 4 .el .IP "\f(CW$plugin\fR\->learner_new ()" 4 .IX Item "$plugin->learner_new ()" Used to support human-trained probabilistic classifiers like the BAYES_* ruleset. Called when a new \f(CW\*(C`Mail::SpamAssassin::Bayes\*(C'\fR object has been created; typically when a new user's scan is about to start. .ie n .IP "$plugin\->learn_message ()" 4 .el .IP "\f(CW$plugin\fR\->learn_message ()" 4 .IX Item "$plugin->learn_message ()" Train the classifier with a training message. .RS 4 .IP "isspam" 4 .IX Item "isspam" 1 if the message is spam, 0 if it's non-spam. .IP "msg" 4 .IX Item "msg" The message's \f(CW\*(C`Mail::SpamAssassin::Message\*(C'\fR object. .IP "id" 4 .IX Item "id" An optional message-identification string, used internally to tag the message. If it is \f(CW\*(C`undef\*(C'\fR, one will be generated. It should be unique to that message. .RE .RS 4 .RE .ie n .IP "$plugin\->forget_message ()" 4 .el .IP "\f(CW$plugin\fR\->forget_message ()" 4 .IX Item "$plugin->forget_message ()" Tell the classifier to 'forget' its training about a specific message. .RS 4 .IP "msg" 4 .IX Item "msg" The message's \f(CW\*(C`Mail::SpamAssassin::Message\*(C'\fR object. .IP "id" 4 .IX Item "id" An optional message-identification string, used internally to tag the message. If it is \f(CW\*(C`undef\*(C'\fR, one will be generated. It should be unique to that message. .RE .RS 4 .RE .ie n .IP "$plugin\->learner_sync ()" 4 .el .IP "\f(CW$plugin\fR\->learner_sync ()" 4 .IX Item "$plugin->learner_sync ()" Tell the classifier to 'sync' any pending changes against the current user's training database. This is called by \f(CW\*(C`sa\-learn \-\-sync\*(C'\fR. .Sp If you do not need to implement these for your classifier, create an implementation that just contains \f(CW\*(C`return 1\*(C'\fR. .ie n .IP "$plugin\->learner_expire_old_training ()" 4 .el .IP "\f(CW$plugin\fR\->learner_expire_old_training ()" 4 .IX Item "$plugin->learner_expire_old_training ()" Tell the classifier to perform infrequent, time-consuming cleanup of the current user's training database. This is called by \f(CW\*(C`sa\-learn \&\-\-force\-expire\*(C'\fR. .Sp If you do not need to implement these for your classifier, create an implementation that just contains \f(CW\*(C`return 1\*(C'\fR. .ie n .IP "$plugin\->learner_is_scan_available ()" 4 .el .IP "\f(CW$plugin\fR\->learner_is_scan_available ()" 4 .IX Item "$plugin->learner_is_scan_available ()" Should return 1 if it is possible to use the current user's training data for a message-scan operation, or 0 otherwise. .ie n .IP "$plugin\->learner_dump_database ()" 4 .el .IP "\f(CW$plugin\fR\->learner_dump_database ()" 4 .IX Item "$plugin->learner_dump_database ()" Dump information about the current user's training data to \f(CW\*(C`stdout\*(C'\fR. This is called by \f(CW\*(C`sa\-learn \-\-dump\*(C'\fR. .RS 4 .IP "magic" 4 .IX Item "magic" Set to 1 if \*(L"magic\*(R" name-value metadata should be dumped. .IP "toks" 4 .IX Item "toks" Set to 1 if the database of tokens should be dumped. .IP "regex" 4 .IX Item "regex" Either \f(CW\*(C`undef\*(C'\fR to dump all tokens, or a value which specifies a regular expression subset of the tokens to dump. .RE .RS 4 .RE .ie n .IP "$plugin\->learner_close ()" 4 .el .IP "\f(CW$plugin\fR\->learner_close ()" 4 .IX Item "$plugin->learner_close ()" Close any open databases. .RS 4 .IP "quiet" 4 .IX Item "quiet" Set to 1 if warning messages should be suppressed. .RE .RS 4 .RE .SH "HELPER APIS" .IX Header "HELPER APIS" These methods provide an \s-1API\s0 for plugins to register themselves to receive specific events, or control the callback chain behaviour. .ie n .IP "$plugin\->register_eval_rule ($nameofevalsub)" 4 .el .IP "\f(CW$plugin\fR\->register_eval_rule ($nameofevalsub)" 4 .IX Item "$plugin->register_eval_rule ($nameofevalsub)" Plugins that implement an eval test will need to call this, so that SpamAssassin calls into the object when that eval test is encountered. See the \fB\s-1REGISTERING EVAL RULES\s0\fR section for full details. .ie n .IP "$plugin\->register_generated_rule_method ($nameofsub)" 4 .el .IP "\f(CW$plugin\fR\->register_generated_rule_method ($nameofsub)" 4 .IX Item "$plugin->register_generated_rule_method ($nameofsub)" In certain circumstances, plugins may find it useful to compile perl functions from the ruleset, on the fly. It is important to remove these once the \f(CW\*(C`Mail::SpamAssassin\*(C'\fR object is deleted, however, and this \s-1API\s0 allows this. .Sp Once the method \f(CW$nameofsub\fR has been generated, call this \s-1API\s0 with the name of the method (including full package scope). This indicates that it's a temporary piece of generated code, built from the SpamAssassin ruleset, and when \&\f(CW\*(C`Mail::SpamAssassin::finish()\*(C'\fR is called, the method will be destroyed. .Sp This \s-1API\s0 was added in SpamAssassin 3.2.0. .ie n .IP "$plugin\->register_method_priority($methodname, $priority)" 4 .el .IP "\f(CW$plugin\fR\->register_method_priority($methodname, \f(CW$priority\fR)" 4 .IX Item "$plugin->register_method_priority($methodname, $priority)" Indicate that the method named \f(CW$methodname\fR on the current object has a callback priority of \f(CW$priority\fR. .Sp This is used by the plugin handler to determine the relative order of callbacks; plugins with lower-numbered priorities are called before plugins with higher-numbered priorities. Each method can have a different priority value. The default value is \f(CW0\fR. The ordering of callbacks to methods with equal priority is undefined. .Sp Typically, you only need to worry about this if you need to ensure your plugin's method is called before another plugin's implementation of that method. It should be called from your plugin's constructor. .Sp This \s-1API\s0 was added in SpamAssassin 3.2.0. .ie n .IP "$plugin\->\fIinhibit_further_callbacks()\fR" 4 .el .IP "\f(CW$plugin\fR\->\fIinhibit_further_callbacks()\fR" 4 .IX Item "$plugin->inhibit_further_callbacks()" Tells the plugin handler to inhibit calling into other plugins in the plugin chain for the current callback. Frequently used when parsing configuration settings using \f(CW\*(C`parse_config()\*(C'\fR. .SH "LOGGING" .IX Header "LOGGING" .IP "Mail::SpamAssassin::Plugin::dbg($message)" 4 .IX Item "Mail::SpamAssassin::Plugin::dbg($message)" Output a debugging message \f(CW$message\fR, if the SpamAssassin object is running with debugging turned on. .Sp \&\fI\s-1NOTE:\s0\fR This function is not available in the package namespace of general plugins and can't be called via \f(CW$self\fR\->\fIdbg()\fR. If a plugin wishes to output debug information, it should call \&\f(CW\*(C`Mail::SpamAssassin::Plugin::dbg($msg)\*(C'\fR. .IP "Mail::SpamAssassin::Plugin::info($message)" 4 .IX Item "Mail::SpamAssassin::Plugin::info($message)" Output an informational message \f(CW$message\fR, if the SpamAssassin object is running with informational messages turned on. .Sp \&\fI\s-1NOTE:\s0\fR This function is not available in the package namespace of general plugins and can't be called via \f(CW$self\fR\->\fIinfo()\fR. If a plugin wishes to output debug information, it should call \&\f(CW\*(C`Mail::SpamAssassin::Plugin::info($msg)\*(C'\fR. .Sp In general, it is better for plugins to use the \f(CW\*(C`Mail::SpamAssassin::Logger\*(C'\fR module to import \f(CW\*(C`dbg\*(C'\fR and \f(CW\*(C`info\*(C'\fR directly, like so: .Sp .Vb 3 \& use Mail::SpamAssassin::Logger; \& dbg("some message"); \& info("some other message"); .Ve .SH "REGISTERING EVAL RULES" .IX Header "REGISTERING EVAL RULES" Plugins that implement an eval test must register the methods that can be called from rules in the configuration files, in the plugin class' constructor. .PP For example, .PP .Vb 1 \& $plugin\->register_eval_rule (\*(Aqcheck_for_foo\*(Aq) .Ve .PP will cause \f(CW\*(C`$plugin\->check_for_foo()\*(C'\fR to be called for this SpamAssassin rule: .PP .Vb 1 \& header FOO_RULE eval:check_for_foo() .Ve .PP Note that eval rules are passed the following arguments: .IP "\- The plugin object itself" 4 .IX Item "- The plugin object itself" .PD 0 .ie n .IP "\- The ""Mail::SpamAssassin::PerMsgStatus"" object calling the rule" 4 .el .IP "\- The \f(CWMail::SpamAssassin::PerMsgStatus\fR object calling the rule" 4 .IX Item "- The Mail::SpamAssassin::PerMsgStatus object calling the rule" .IP "\- standard arguments for the rule type in use" 4 .IX Item "- standard arguments for the rule type in use" .IP "\- any and all arguments as specified in the configuration file" 4 .IX Item "- any and all arguments as specified in the configuration file" .PD .PP In other words, the eval test method should look something like this: .PP .Vb 4 \& sub check_for_foo { \& my ($self, $permsgstatus, ...arguments...) = @_; \& ...code returning 0 or 1 \& } .Ve .PP Note that the headers can be accessed using the \f(CW\*(C`get()\*(C'\fR method on the \&\f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR object, and the body by \&\f(CW\*(C`get_decoded_stripped_body_text_array()\*(C'\fR and other similar methods. Similarly, the \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR object holding the current configuration may be accessed through \f(CW\*(C`$permsgstatus\->{main}\->{conf}\*(C'\fR. .PP The eval rule should return \f(CW1\fR for a hit, or \f(CW0\fR if the rule is not hit. .PP State for a single message being scanned should be stored on the \f(CW$permsgstatus\fR object, not on the \f(CW$self\fR object, since \f(CW$self\fR persists between scan operations. See the 'lifecycle note' on the \f(CW\*(C`check_start()\*(C'\fR method above. .SH "STANDARD ARGUMENTS FOR RULE TYPES" .IX Header "STANDARD ARGUMENTS FOR RULE TYPES" Plugins will be called with the same arguments as a standard EvalTest. Different rule types receive different information by default: .IP "\- header tests: no extra arguments" 4 .IX Item "- header tests: no extra arguments" .PD 0 .IP "\- body tests: fully rendered message as array reference" 4 .IX Item "- body tests: fully rendered message as array reference" .IP "\- rawbody tests: fully decoded message as array reference" 4 .IX Item "- rawbody tests: fully decoded message as array reference" .IP "\- full tests: pristine message as scalar reference" 4 .IX Item "- full tests: pristine message as scalar reference" .PD .PP The configuration file arguments will be passed in after the standard arguments. .SH "BACKWARD COMPATIBILITY" .IX Header "BACKWARD COMPATIBILITY" Note that if you write a plugin and need to determine if a particular helper method is supported on \f(CW\*(C`Mail::SpamAssassin::Plugin\*(C'\fR, you can do this: .PP .Vb 7 \& if ($self\->can("name_of_method")) { \& eval { \& $self\->name_of_method(); # etc. \& } \& } else { \& # take fallback action \& } .Ve .PP The same applies for the public APIs on objects of other types, such as \&\f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\f(CW\*(C`Mail::SpamAssassin\*(C'\fR .PP \&\f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR .PP http://wiki.apache.org/spamassassin/PluginWritingTips .PP http://issues.apache.org/SpamAssassin/show_bug.cgi?id=2163