.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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 >0, 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 3pm" .TH Mail::SpamAssassin 3pm "2022-09-10" "perl v5.34.0" "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 \- Spam detector and markup engine .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& my $spamtest = Mail::SpamAssassin\->new(); \& my $mail = $spamtest\->parse($message); \& my $status = $spamtest\->check($mail); \& \& if ($status\->is_spam()) { \& $message = $status\->rewrite_mail(); \& } \& else { \& ... \& } \& ... \& \& $status\->finish(); \& $mail\->finish(); \& $spamtest\->finish(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mail::SpamAssassin is a module to identify spam using several methods including text analysis, internet-based realtime blocklists, statistical analysis, and internet-based hashing algorithms. .PP Using its rule base, it uses a wide range of heuristic tests on mail headers and body text to identify \*(L"spam\*(R", also known as unsolicited bulk email. Once identified as spam, the mail can then be tagged as spam for later filtering using the user's own mail user agent application or at the mail transfer agent. .PP If you wish to use a command-line filter tool, try the \f(CW\*(C`spamassassin\*(C'\fR or the \f(CW\*(C`spamd\*(C'\fR/\f(CW\*(C`spamc\*(C'\fR tools provided. .SH "METHODS" .IX Header "METHODS" .ie n .IP "$t = Mail::SpamAssassin\->new( { opt => val, ... } )" 4 .el .IP "\f(CW$t\fR = Mail::SpamAssassin\->new( { opt => val, ... } )" 4 .IX Item "$t = Mail::SpamAssassin->new( { opt => val, ... } )" Constructs a new \f(CW\*(C`Mail::SpamAssassin\*(C'\fR object. You may pass a hash reference to the constructor which may contain the following attribute\- value pairs. .RS 4 .IP "debug" 4 .IX Item "debug" This is the debug options used to determine logging level. It exists to allow sections of debug messages (called \*(L"facilities\*(R") to be enabled or disabled. If this is a string, it is treated as a comma-delimited list of the debug facilities. If it's a hash reference, then the keys are treated as the list of debug facilities and if it's a array reference, then the elements are treated as the list of debug facilities. .Sp There are also two special cases: (1) if the special case of \*(L"info\*(R" is passed as a debug facility, then all informational messages are enabled; (2) if the special case of \*(L"all\*(R" is passed as a debug facility, then all debugging facilities are enabled. .IP "rules_filename" 4 .IX Item "rules_filename" The filename/directory to load spam-identifying rules from. (optional) .IP "site_rules_filename" 4 .IX Item "site_rules_filename" The filename/directory to load site-specific spam-identifying rules from. (optional) .IP "userprefs_filename" 4 .IX Item "userprefs_filename" The filename to load preferences from. (optional) .IP "userstate_dir" 4 .IX Item "userstate_dir" The directory user state is stored in. (optional) .IP "config_tree_recurse" 4 .IX Item "config_tree_recurse" Set to \f(CW1\fR to recurse through directories when reading configuration files, instead of just reading a single level. (optional, default 0) .IP "config_text" 4 .IX Item "config_text" The text of all rules and preferences. If you prefer not to load the rules from files, read them in yourself and set this instead. As a result, this will override the settings for \f(CW\*(C`rules_filename\*(C'\fR, \f(CW\*(C`site_rules_filename\*(C'\fR, and \f(CW\*(C`userprefs_filename\*(C'\fR. .IP "pre_config_text" 4 .IX Item "pre_config_text" Similar to \f(CW\*(C`config_text\*(C'\fR, this text is placed before config_text to allow an override of config files. .IP "post_config_text" 4 .IX Item "post_config_text" Similar to \f(CW\*(C`config_text\*(C'\fR, this text is placed after config_text to allow an override of config files. .IP "force_ipv4" 4 .IX Item "force_ipv4" If set to 1, \s-1DNS\s0 or other network tests will prefer IPv4 and not attempt to use IPv6. Use if the existing tests for IPv6 availability produce incorrect results or crashes. .IP "force_ipv6" 4 .IX Item "force_ipv6" For symmetry with force_ipv4: if set to 1, \s-1DNS\s0 or other network tests will prefer IPv6 and not attempt to use IPv4. Some plugins may disregard this setting and use whatever protocol family they are comfortable with. .IP "require_rules" 4 .IX Item "require_rules" If set to 1, \fBinit()\fR will die if no valid rules could be loaded. This is the default behaviour when called by \f(CW\*(C`spamassassin\*(C'\fR or \f(CW\*(C`spamd\*(C'\fR. .IP "languages_filename" 4 .IX Item "languages_filename" If you want to be able to use the language-guessing rule \&\f(CW\*(C`UNWANTED_LANGUAGE_BODY\*(C'\fR, and are using \f(CW\*(C`config_text\*(C'\fR instead of \&\f(CW\*(C`rules_filename\*(C'\fR, \f(CW\*(C`site_rules_filename\*(C'\fR, and \f(CW\*(C`userprefs_filename\*(C'\fR, you will need to set this. It should be the path to the \fBlanguages\fR file normally found in the SpamAssassin \fBrules\fR directory. .IP "local_tests_only" 4 .IX Item "local_tests_only" If set to 1, no tests that require internet access will be performed. (default: 0) .IP "need_tags" 4 .IX Item "need_tags" The option provides a way to avoid more expensive processing when it is known in advance that some information will not be needed by a caller. .Sp A value of the option can either be a string (a comma-delimited list of tag names), or a reference to a list of individual tag names. A caller may provide the list in advance, specifying his intention to later collect the information through \f(CW$pms\fR\->\fBget_tag()\fR calls. If a name of a tag starts with a '\s-1NO\s0' (case insensitive), it shows that a caller will not be interested in such tag, although there is no guarantee it would save any resources, nor that a tag value will be empty. Currently no built-in tags start with '\s-1NO\s0'. A later entry overrides previous one, e.g. \s-1ASN,NOASN,ASN,TIMING,NOASN\s0 is equivalent to \s-1TIMING,NOASN.\s0 .Sp For backward compatibility, all tags available as of version 3.2.4 will be available by default (unless disabled by NOtag), even if not requested through need_tags option. Future versions may provide new tags conditionally available. .Sp Currently the only tag that needs to be explicitly requested is '\s-1TIMING\s0'. Not requesting it can save a millisecond or two \- it mostly serves to illustrate the usage of need_tags. .Sp Example: need_tags => '\s-1TIMING\s0,noLANGUAGES,RELAYCOUNTRY,ASN,noASNCIDR', or: need_tags => [qw(\s-1TIMING\s0 noLANGUAGES \s-1RELAYCOUNTRY ASN\s0 noASNCIDR)], .IP "ignore_site_cf_files" 4 .IX Item "ignore_site_cf_files" If set to 1, any rule files found in the \f(CW\*(C`site_rules_filename\*(C'\fR directory will be ignored. *.pre files (used for loading plugins) found in the \&\f(CW\*(C`site_rules_filename\*(C'\fR directory will still be used. (default: 0) .IP "dont_copy_prefs" 4 .IX Item "dont_copy_prefs" If set to 1, the user preferences file will not be created if it doesn't already exist. (default: 0) .IP "save_pattern_hits" 4 .IX Item "save_pattern_hits" If set to 1, the patterns hit can be retrieved from the \&\f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR object. Used for debugging. .IP "home_dir_for_helpers" 4 .IX Item "home_dir_for_helpers" If set, the \fB\s-1HOME\s0\fR environment variable will be set to this value when using test applications that require their configuration data, such as Razor, Pyzor and \s-1DCC.\s0 .IP "username" 4 .IX Item "username" If set, the \f(CW\*(C`username\*(C'\fR attribute will use this as the current user's name. Otherwise, the default is taken from the runtime environment (ie. this process' effective \s-1UID\s0 under \s-1UNIX\s0). .IP "skip_prng_reseeding" 4 .IX Item "skip_prng_reseeding" If skip_prng_reseeding is set to true, the SpamAssassin library will \fBnot\fR call \fBsrand()\fR to reseed a pseudo-random number generator (\s-1PRNG\s0). The \fBsrand()\fR Perl function should be called during initialization of each child process, soon after forking. .Sp Prior to version 3.4.0, calling \fBsrand()\fR was handled by the SpamAssassin library. .Sp This setting requires the caller to decide when to call \fBsrand()\fR. This choice may be desired to preserve the entropy of a \s-1PRNG.\s0 The default value of skip_prng_reseeding is false to maintain backward compatibility. .Sp This option should only be set by a caller if it calls \fBsrand()\fR upon spawning child processes. Unless you are certain you need it, leave this setting as false. .Sp \&\s-1NOTE:\s0 The skip_prng_reseeding feature is implemented in spamd as of 3.4.0 which allows spamd to call \fBsrand()\fR right after forking a child process. .RE .RS 4 .Sp If none of \f(CW\*(C`rules_filename\*(C'\fR, \f(CW\*(C`site_rules_filename\*(C'\fR, \f(CW\*(C`userprefs_filename\*(C'\fR, or \&\f(CW\*(C`config_text\*(C'\fR is set, the \f(CW\*(C`Mail::SpamAssassin\*(C'\fR module will search for the configuration files in the usual installed locations using the below variable definitions which can be passed in. .IP "\s-1PREFIX\s0" 4 .IX Item "PREFIX" Used as the root for certain directory paths such as: .Sp .Vb 2 \& \*(Aq_\|_prefix_\|_/etc/mail/spamassassin\*(Aq \& \*(Aq_\|_prefix_\|_/etc/spamassassin\*(Aq .Ve .Sp Defaults to \*(L"@@PREFIX@@\*(R". .IP "\s-1DEF_RULES_DIR\s0" 4 .IX Item "DEF_RULES_DIR" Location where the default rules are installed. Defaults to \&\*(L"@@DEF_RULES_DIR@@\*(R". .IP "\s-1LOCAL_RULES_DIR\s0" 4 .IX Item "LOCAL_RULES_DIR" Location where the local site rules are installed. Defaults to \&\*(L"@@LOCAL_RULES_DIR@@\*(R". .IP "\s-1LOCAL_STATE_DIR\s0" 4 .IX Item "LOCAL_STATE_DIR" Location of the local state directory, mainly used for installing updates via \&\f(CW\*(C`sa\-update\*(C'\fR and compiling rulesets to native code. Defaults to \&\*(L"@@LOCAL_STATE_DIR@@\*(R". .RE .RS 4 .RE .ie n .IP "parse($message, $parse_now [, $suppl_attrib])" 4 .el .IP "parse($message, \f(CW$parse_now\fR [, \f(CW$suppl_attrib\fR])" 4 .IX Item "parse($message, $parse_now [, $suppl_attrib])" Parse will return a Mail::SpamAssassin::Message object with just the headers parsed. When calling this function, there are two optional parameters that can be passed in: \f(CW$message\fR is either undef (which will use \s-1STDIN\s0), a scalar \- a string containing an entire message, a reference to such string, an array reference of the message with one line per array element, or either a file glob or an IO::File object which holds the entire contents of the message; and \f(CW$parse_now\fR, which specifies whether or not to create a \s-1MIME\s0 tree at parse time or later as necessary. .Sp The \fI\f(CI$parse_now\fI\fR option, by default, is set to false (0). This allows SpamAssassin to not have to generate the tree of internal data nodes if the information is not going to be used. This is handy, for instance, when running \f(CW\*(C`spamassassin \-d\*(C'\fR, which only needs the pristine header and body which is always parsed and stored by this function. .Sp The optional last argument \fI\f(CI$suppl_attrib\fI\fR provides a way for a caller to pass additional information about a message to SpamAssassin. It is either undef, or a ref to a hash where each key/value pair provides some supplementary attribute of the message, typically information that cannot be deduced from the message itself, or is hard to do so reliably, or would represent unnecessary work for SpamAssassin to obtain it. The argument will be stored to a Mail::SpamAssassin::Message object as 'suppl_attrib', thus made available to the rest of the code as well as to plugins. The exact list of attributes will evolve through time, any unknown attribute should be ignored. Possible examples are: \s-1SMTP\s0 envelope information, a flag indicating that a message as supplied by a caller was truncated due to size limit, an already verified list of \s-1DKIM\s0 signature objects, or perhaps a list of rule hits predetermined by a caller, which makes another possible way for a caller to provide meta information (instead of having to insert made-up header fields in order to pass information), or maybe just plain rule hits. .Sp For more information, please see the \f(CW\*(C`Mail::SpamAssassin::Message\*(C'\fR and \f(CW\*(C`Mail::SpamAssassin::Message::Node\*(C'\fR \s-1POD.\s0 .ie n .IP "$status = $f\->check ($mail)" 4 .el .IP "\f(CW$status\fR = \f(CW$f\fR\->check ($mail)" 4 .IX Item "$status = $f->check ($mail)" Check a mail, encapsulated in a \f(CW\*(C`Mail::SpamAssassin::Message\*(C'\fR object, to determine if it is spam or not. .Sp Returns a \f(CW\*(C`Mail::SpamAssassin::PerMsgStatus\*(C'\fR object which can be used to test or manipulate the mail message. .Sp Note that the \f(CW\*(C`Mail::SpamAssassin\*(C'\fR object can be re-used for further messages without affecting this check; in \s-1OO\s0 terminology, the \f(CW\*(C`Mail::SpamAssassin\*(C'\fR object is a \*(L"factory\*(R". However, if you do this, be sure to call the \&\f(CW\*(C`finish()\*(C'\fR method on the status objects when you're done with them. .ie n .IP "$status = $f\->check_message_text ($mailtext)" 4 .el .IP "\f(CW$status\fR = \f(CW$f\fR\->check_message_text ($mailtext)" 4 .IX Item "$status = $f->check_message_text ($mailtext)" Check a mail, encapsulated in a plain string \f(CW$mailtext\fR, to determine if it is spam or not. .Sp Otherwise identical to \f(CW\*(C`check()\*(C'\fR above. .ie n .IP "$status = $f\->learn ($mail, $id, $isspam, $forget)" 4 .el .IP "\f(CW$status\fR = \f(CW$f\fR\->learn ($mail, \f(CW$id\fR, \f(CW$isspam\fR, \f(CW$forget\fR)" 4 .IX Item "$status = $f->learn ($mail, $id, $isspam, $forget)" Learn from a mail, encapsulated in a \f(CW\*(C`Mail::SpamAssassin::Message\*(C'\fR object. .Sp If \f(CW$isspam\fR is set, the mail is assumed to be spam, otherwise it will be learnt as non-spam. .Sp If \f(CW$forget\fR is set, the attributes of the mail will be removed from both the non-spam and spam learning databases. .Sp \&\f(CW$id\fR is an optional message-identification string, used internally to tag the message. If it is \f(CW\*(C`undef\*(C'\fR, the Message-Id of the message will be used. It should be unique to that message. .Sp Returns a \f(CW\*(C`Mail::SpamAssassin::PerMsgLearner\*(C'\fR object which can be used to manipulate the learning process for each mail. .Sp Note that the \f(CW\*(C`Mail::SpamAssassin\*(C'\fR object can be re-used for further messages without affecting this check; in \s-1OO\s0 terminology, the \f(CW\*(C`Mail::SpamAssassin\*(C'\fR object is a \*(L"factory\*(R". However, if you do this, be sure to call the \&\f(CW\*(C`finish()\*(C'\fR method on the learner objects when you're done with them. .Sp \&\f(CW\*(C`learn()\*(C'\fR and \f(CW\*(C`check()\*(C'\fR can be run using the same factory. \f(CW\*(C`init_learner()\*(C'\fR must be called before using this method. .ie n .IP "$f\->init_learner ( [ { opt => val, ... } ] )" 4 .el .IP "\f(CW$f\fR\->init_learner ( [ { opt => val, ... } ] )" 4 .IX Item "$f->init_learner ( [ { opt => val, ... } ] )" Initialise learning. You may pass the following attribute-value pairs to this method. .RS 4 .IP "caller_will_untie" 4 .IX Item "caller_will_untie" Whether or not the code calling this method will take care of untie'ing from the Bayes databases (by calling \f(CW\*(C`finish_learner()\*(C'\fR) (optional, default 0). .IP "force_expire" 4 .IX Item "force_expire" Should an expiration run be forced to occur immediately? (optional, default 0). .IP "learn_to_journal" 4 .IX Item "learn_to_journal" Should learning data be written to the journal, instead of directly to the databases? (optional, default 0). .IP "wait_for_lock" 4 .IX Item "wait_for_lock" Whether or not to wait a long time for locks to complete (optional, default 0). .IP "opportunistic_expire_check_only" 4 .IX Item "opportunistic_expire_check_only" During the opportunistic journal sync and expire check, don't actually do the expire but report back whether or not it should occur (optional, default 0). .IP "no_relearn" 4 .IX Item "no_relearn" If doing a learn operation, and the message has already been learned as the opposite type, don't re-learn the message. .RE .RS 4 .RE .ie n .IP "$f\->rebuild_learner_caches ({ opt => val })" 4 .el .IP "\f(CW$f\fR\->rebuild_learner_caches ({ opt => val })" 4 .IX Item "$f->rebuild_learner_caches ({ opt => val })" Rebuild any cache databases; should be called after the learning process. Options include: \f(CW\*(C`verbose\*(C'\fR, which will output diagnostics to \f(CW\*(C`stdout\*(C'\fR if set to 1. .ie n .IP "$f\->finish_learner ()" 4 .el .IP "\f(CW$f\fR\->finish_learner ()" 4 .IX Item "$f->finish_learner ()" Finish learning. .ie n .IP "$f\->\fBdump_bayes_db()\fR" 4 .el .IP "\f(CW$f\fR\->\fBdump_bayes_db()\fR" 4 .IX Item "$f->dump_bayes_db()" Dump the contents of the Bayes \s-1DB\s0 .ie n .IP "$f\->signal_user_changed ( [ { opt => val, ... } ] )" 4 .el .IP "\f(CW$f\fR\->signal_user_changed ( [ { opt => val, ... } ] )" 4 .IX Item "$f->signal_user_changed ( [ { opt => val, ... } ] )" Signals that the current user has changed (possibly using \f(CW\*(C`setuid\*(C'\fR), meaning that SpamAssassin should close any per-user databases it has open, and re-open using ones appropriate for the new user. .Sp Note that this should be called \fIafter\fR reading any per-user configuration, as that data may override some paths opened in this method. You may pass the following attribute-value pairs: .RS 4 .IP "username" 4 .IX Item "username" The username of the user. This will be used for the \f(CW\*(C`username\*(C'\fR attribute. .IP "user_dir" 4 .IX Item "user_dir" A directory to use as a 'home directory' for the current user's data, overriding the system default. This directory must be readable and writable by the process. Note that the resulting \f(CW\*(C`userstate_dir\*(C'\fR will be the \&\f(CW\*(C`.spamassassin\*(C'\fR subdirectory of this dir. .IP "userstate_dir" 4 .IX Item "userstate_dir" A directory to use as a directory for the current user's data, overriding the system default. This directory must be readable and writable by the process. The default is \f(CW\*(C`user_dir/.spamassassin\*(C'\fR. .RE .RS 4 .RE .ie n .IP "$f\->report_as_spam ($mail, $options)" 4 .el .IP "\f(CW$f\fR\->report_as_spam ($mail, \f(CW$options\fR)" 4 .IX Item "$f->report_as_spam ($mail, $options)" Report a mail, encapsulated in a \f(CW\*(C`Mail::SpamAssassin::Message\*(C'\fR object, as human-verified spam. This will submit the mail message to live, collaborative, spam-blocker databases, allowing other users to block this message. .Sp It will also submit the mail to SpamAssassin's Bayesian learner. .Sp Options is an optional reference to a hash of options. Currently these can be: .RS 4 .IP "dont_report_to_dcc" 4 .IX Item "dont_report_to_dcc" Inhibits reporting of the spam to \s-1DCC.\s0 .IP "dont_report_to_pyzor" 4 .IX Item "dont_report_to_pyzor" Inhibits reporting of the spam to Pyzor. .IP "dont_report_to_razor" 4 .IX Item "dont_report_to_razor" Inhibits reporting of the spam to Razor. .IP "dont_report_to_spamcop" 4 .IX Item "dont_report_to_spamcop" Inhibits reporting of the spam to SpamCop. .RE .RS 4 .RE .ie n .IP "$f\->revoke_as_spam ($mail, $options)" 4 .el .IP "\f(CW$f\fR\->revoke_as_spam ($mail, \f(CW$options\fR)" 4 .IX Item "$f->revoke_as_spam ($mail, $options)" Revoke a mail, encapsulated in a \f(CW\*(C`Mail::SpamAssassin::Message\*(C'\fR object, as human-verified ham (non-spam). This will revoke the mail message from live, collaborative, spam-blocker databases, allowing other users to block this message. .Sp It will also submit the mail to SpamAssassin's Bayesian learner as nonspam. .Sp Options is an optional reference to a hash of options. Currently these can be: .RS 4 .IP "dont_report_to_razor" 4 .IX Item "dont_report_to_razor" Inhibits revoking of the spam to Razor. .RE .RS 4 .RE .ie n .IP "$f\->add_address_to_welcomelist ($addr, $cli_p)" 4 .el .IP "\f(CW$f\fR\->add_address_to_welcomelist ($addr, \f(CW$cli_p\fR)" 4 .IX Item "$f->add_address_to_welcomelist ($addr, $cli_p)" Previously add_address_to_whitelist which will work interchangeably until 4.1. .Sp Given a string containing an email address, add it to the automatic welcomelist database. .Sp If \f(CW$cli_p\fR is set then underlying plugin may give visual feedback on additions/failures. .ie n .IP "$f\->add_all_addresses_to_welcomelist ($mail, $cli_p)" 4 .el .IP "\f(CW$f\fR\->add_all_addresses_to_welcomelist ($mail, \f(CW$cli_p\fR)" 4 .IX Item "$f->add_all_addresses_to_welcomelist ($mail, $cli_p)" Previously add_all_addresses_to_whitelist which will work interchangeably until 4.1. .Sp Given a mail message, find as many addresses in the usual headers (To, Cc, From etc.), and the message body, and add them to the automatic welcomelist database. .Sp If \f(CW$cli_p\fR is set then underlying plugin may give visual feedback on additions/failures. .ie n .IP "$f\->remove_address_from_welcomelist ($addr, $cli_p)" 4 .el .IP "\f(CW$f\fR\->remove_address_from_welcomelist ($addr, \f(CW$cli_p\fR)" 4 .IX Item "$f->remove_address_from_welcomelist ($addr, $cli_p)" Previously remove_address_from_whitelist which will work interchangeably until 4.1. .Sp Given a string containing an email address, remove it from the automatic welcomelist database. .Sp If \f(CW$cli_p\fR is set then underlying plugin may give visual feedback on additions/failures. .ie n .IP "$f\->remove_all_addresses_from_welcomelist ($mail, $cli_p)" 4 .el .IP "\f(CW$f\fR\->remove_all_addresses_from_welcomelist ($mail, \f(CW$cli_p\fR)" 4 .IX Item "$f->remove_all_addresses_from_welcomelist ($mail, $cli_p)" Previously remove_all_addresses_from_whitelist which will work interchangeably until 4.1. .Sp Given a mail message, find as many addresses in the usual headers (To, Cc, From etc.), and the message body, and remove them from the automatic welcomelist database. .Sp If \f(CW$cli_p\fR is set then underlying plugin may give visual feedback on additions/failures. .ie n .IP "$f\->add_address_to_blocklist ($addr, $cli_p)" 4 .el .IP "\f(CW$f\fR\->add_address_to_blocklist ($addr, \f(CW$cli_p\fR)" 4 .IX Item "$f->add_address_to_blocklist ($addr, $cli_p)" Previously add_address_to_blacklist which will work interchangeably until 4.1. .Sp Given a string containing an email address, add it to the automatic welcomelist database with a high score, effectively blocklisting them. .Sp If \f(CW$cli_p\fR is set then underlying plugin may give visual feedback on additions/failures. .ie n .IP "$f\->add_all_addresses_to_blocklist ($mail, $cli_p)" 4 .el .IP "\f(CW$f\fR\->add_all_addresses_to_blocklist ($mail, \f(CW$cli_p\fR)" 4 .IX Item "$f->add_all_addresses_to_blocklist ($mail, $cli_p)" Previously add_all_addresses_to_blacklist which will work interchangeably until 4.1. .Sp Given a mail message, find addresses in the From headers and add them to the automatic welcomelist database with a high score, effectively blocklisting them. .Sp Note that To and Cc addresses are not used. .Sp If \f(CW$cli_p\fR is set then underlying plugin may give visual feedback on additions/failures. .ie n .IP "$text = $f\->remove_spamassassin_markup ($mail)" 4 .el .IP "\f(CW$text\fR = \f(CW$f\fR\->remove_spamassassin_markup ($mail)" 4 .IX Item "$text = $f->remove_spamassassin_markup ($mail)" Returns the text of the message, with any SpamAssassin-added text (such as the report, or X\-Spam-Status headers) stripped. .Sp Note that the \fB\f(CB$mail\fB\fR object is not modified. .Sp Warning: if the input message in \fB\f(CB$mail\fB\fR contains a mixture of CR-LF (Windows-style) and \s-1LF\s0 (UNIX-style) line endings, it will be \*(L"canonicalized\*(R" to use one or the other consistently throughout. .ie n .IP "$f\->read_scoreonly_config ($filename)" 4 .el .IP "\f(CW$f\fR\->read_scoreonly_config ($filename)" 4 .IX Item "$f->read_scoreonly_config ($filename)" Read a configuration file and parse user preferences from it. .Sp User preferences are as defined in the \f(CW\*(C`Mail::SpamAssassin::Conf\*(C'\fR manual page. In other words, they include scoring options, scores, welcomelists and blocklists, and so on, but do not include rule definitions, privileged settings, etc. unless \f(CW\*(C`allow_user_rules\*(C'\fR is enabled; and they never include the administrator settings. .ie n .IP "$f\->load_scoreonly_sql ($username)" 4 .el .IP "\f(CW$f\fR\->load_scoreonly_sql ($username)" 4 .IX Item "$f->load_scoreonly_sql ($username)" Read configuration parameters from \s-1SQL\s0 database and parse scores from it. This will only take effect if the perl \f(CW\*(C`DBI\*(C'\fR module is installed, and the configuration parameters \f(CW\*(C`user_scores_dsn\*(C'\fR, \f(CW\*(C`user_scores_sql_username\*(C'\fR, and \&\f(CW\*(C`user_scores_sql_password\*(C'\fR are set correctly. .Sp The username in \f(CW$username\fR will also be used for the \f(CW\*(C`username\*(C'\fR attribute of the Mail::SpamAssassin object. .ie n .IP "$f\->load_scoreonly_ldap ($username)" 4 .el .IP "\f(CW$f\fR\->load_scoreonly_ldap ($username)" 4 .IX Item "$f->load_scoreonly_ldap ($username)" Read configuration parameters from an \s-1LDAP\s0 server and parse scores from it. This will only take effect if the perl \f(CW\*(C`Net::LDAP\*(C'\fR and \f(CW\*(C`URI\*(C'\fR modules are installed, and the configuration parameters \f(CW\*(C`user_scores_dsn\*(C'\fR, \&\f(CW\*(C`user_scores_ldap_username\*(C'\fR, and \f(CW\*(C`user_scores_ldap_password\*(C'\fR are set correctly. .Sp The username in \f(CW$username\fR will also be used for the \f(CW\*(C`username\*(C'\fR attribute of the Mail::SpamAssassin object. .ie n .IP "$f\->set_persistent_address_list_factory ($factoryobj)" 4 .el .IP "\f(CW$f\fR\->set_persistent_address_list_factory ($factoryobj)" 4 .IX Item "$f->set_persistent_address_list_factory ($factoryobj)" Set the persistent address list factory, used to create objects for the automatic welcomelist algorithm's persistent-storage back-end. See \&\f(CW\*(C`Mail::SpamAssassin::PersistentAddrList\*(C'\fR for the \s-1API\s0 these factory objects must implement, and the \s-1API\s0 the objects they produce must implement. .ie n .IP "$f\->compile_now ($use_user_prefs, $keep_userstate)" 4 .el .IP "\f(CW$f\fR\->compile_now ($use_user_prefs, \f(CW$keep_userstate\fR)" 4 .IX Item "$f->compile_now ($use_user_prefs, $keep_userstate)" Compile all patterns, load all configuration files, and load all possibly-required Perl modules. .Sp Normally, Mail::SpamAssassin uses lazy evaluation where possible, but if you plan to \fBfork()\fR or start a new perl interpreter thread to process a message, this is suboptimal, as each process/thread will have to perform these actions. .Sp Call this function in the master thread or process to perform the actions straight away, so that the sub-processes will not have to. .Sp If \f(CW$use_user_prefs\fR is 0, this will initialise the SpamAssassin configuration without reading the per-user configuration file and it will assume that you will call \f(CW\*(C`read_scoreonly_config\*(C'\fR at a later point. .Sp If \f(CW$keep_userstate\fR is true, \fBcompile_now()\fR will revert any configuration options which have a default with \fI_\|_userstate_\|_\fR in it post\-\fBinit()\fR, and then re-change the option before returning. This lets you change \&\fI\f(CI$ENV\fI{'\s-1HOME\s0'}\fR to a temp directory, have \fBcompile_now()\fR and create any files there as necessary without disturbing the actual files as changed by a configuration option. By default, this is disabled. .ie n .IP "$f\->debug_diagnostics ()" 4 .el .IP "\f(CW$f\fR\->debug_diagnostics ()" 4 .IX Item "$f->debug_diagnostics ()" Output some diagnostic information, useful for debugging SpamAssassin problems. .ie n .IP "$failed = $f\->lint_rules ()" 4 .el .IP "\f(CW$failed\fR = \f(CW$f\fR\->lint_rules ()" 4 .IX Item "$failed = $f->lint_rules ()" Syntax-check the current set of rules. Returns the number of syntax errors discovered, or 0 if the configuration is valid. .ie n .IP "$f\->\fBfinish()\fR" 4 .el .IP "\f(CW$f\fR\->\fBfinish()\fR" 4 .IX Item "$f->finish()" Destroy this object, so that it will be garbage-collected once it goes out of scope. The object will no longer be usable after this method is called. .ie n .IP "$fullpath = $f\->find_rule_support_file ($filename)" 4 .el .IP "\f(CW$fullpath\fR = \f(CW$f\fR\->find_rule_support_file ($filename)" 4 .IX Item "$fullpath = $f->find_rule_support_file ($filename)" Find a rule-support file, such as \f(CW\*(C`languages\*(C'\fR or \f(CW\*(C`triplets.txt\*(C'\fR, in the system-wide rules directory, and return its full path if it exists, or undef if it doesn't exist. .Sp (This \s-1API\s0 was added in SpamAssassin 3.1.1.) .ie n .IP "$f\->create_default_prefs ($filename, $username [ , $userdir ] )" 4 .el .IP "\f(CW$f\fR\->create_default_prefs ($filename, \f(CW$username\fR [ , \f(CW$userdir\fR ] )" 4 .IX Item "$f->create_default_prefs ($filename, $username [ , $userdir ] )" Copy default preferences file into home directory for later use and modification, if it does not already exist and \f(CW\*(C`dont_copy_prefs\*(C'\fR is not set. .ie n .IP "$f\->copy_config ( [ $source ], [ $dest ] )" 4 .el .IP "\f(CW$f\fR\->copy_config ( [ \f(CW$source\fR ], [ \f(CW$dest\fR ] )" 4 .IX Item "$f->copy_config ( [ $source ], [ $dest ] )" Used for daemons to keep a persistent Mail::SpamAssassin object's configuration correct if switching between users. Pass an associative array reference as either \f(CW$source\fR or \f(CW$dest\fR, and set the other to 'undef' so that the object will use its current configuration. i.e.: .Sp .Vb 2 \& # create object w/ configuration \& my $spamtest = Mail::SpamAssassin\->new( ... ); \& \& # backup configuration to %conf_backup \& my %conf_backup; \& $spamtest\->copy_config(undef, \e%conf_backup) || \& die "config: error returned from copy_config!\en"; \& \& ... do stuff, perhaps modify the config, etc ... \& \& # reset the configuration back to the original \& $spamtest\->copy_config(\e%conf_backup, undef) || \& die "config: error returned from copy_config!\en"; .Ve .Sp Note that the contents of the associative arrays should be considered opaque by calling code. .ie n .IP "@plugins = $f\->get_loaded_plugins_list ( )" 4 .el .IP "\f(CW@plugins\fR = \f(CW$f\fR\->get_loaded_plugins_list ( )" 4 .IX Item "@plugins = $f->get_loaded_plugins_list ( )" Return the list of plugins currently loaded by this SpamAssassin object's configuration; each entry in the list is an object of type \&\f(CW\*(C`Mail::SpamAssassin::Plugin\*(C'\fR. .Sp (This \s-1API\s0 was added in SpamAssassin 3.2.0.) .SH "PREREQUISITES" .IX Header "PREREQUISITES" \&\f(CW\*(C`HTML::Parser\*(C'\fR \&\f(CW\*(C`Sys::Syslog\*(C'\fR .SH "MORE DOCUMENTATION" .IX Header "MORE DOCUMENTATION" See also and for more information. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBMail::SpamAssassin::Conf\fR\|(3) \&\fBMail::SpamAssassin::PerMsgStatus\fR\|(3) \&\fBspamassassin\fR\|(1) \&\fBsa\-update\fR\|(1) .SH "BUGS" .IX Header "BUGS" See .SH "AUTHORS" .IX Header "AUTHORS" The SpamAssassin(tm) Project .SH "COPYRIGHT" .IX Header "COPYRIGHT" SpamAssassin is distributed under the Apache License, Version 2.0, as described in the file \f(CW\*(C`LICENSE\*(C'\fR included with the distribution. .SH "AVAILABILITY" .IX Header "AVAILABILITY" The latest version of this library is likely to be available from \s-1CPAN\s0 as well as: .PP