Mail::SpamAssassin::Conf(3pm) | User Contributed Perl Documentation | Mail::SpamAssassin::Conf(3pm) |
Mail::SpamAssassin::Conf - SpamAssassin configuration file
# a comment rewrite_header Subject *****SPAM***** full PARA_A_2_C_OF_1618 /Paragraph .a.{0,10}2.{0,10}C. of S. 1618/i describe PARA_A_2_C_OF_1618 Claims compliance with senate bill 1618 header FROM_HAS_MIXED_NUMS From =~ /\d+[a-z]+\d+\S*@/i describe FROM_HAS_MIXED_NUMS From: contains numbers mixed in with letters score A_HREF_TO_REMOVE 2.0 lang es describe FROM_FORGED_HOTMAIL Forzado From: simula ser de hotmail.com lang pt_BR report O programa detetor de Spam ZOE [...]
SpamAssassin is configured using traditional UNIX-style configuration files, loaded from the "/usr/share/spamassassin" and "/etc/spamassassin" directories.
The following web page lists the most important configuration settings used to configure SpamAssassin; novices are encouraged to read it first:
https://wiki.apache.org/spamassassin/ImportantInitialConfigItems
The "#" character starts a comment, which continues until end of line. NOTE: if the "#" character is to be used as part of a rule or configuration option, it must be escaped with a backslash. i.e.: "\#"
Whitespace in the files is not significant, but please note that starting a line with whitespace is deprecated, as we reserve its use for multi-line rule definitions, at some point in the future.
Currently, each rule or configuration setting must fit on one-line; multi-line settings are not supported yet.
File and directory paths can use "~" to refer to the user's home directory, but no other shell-style path extensions such as globing or "~user/" are supported.
Where appropriate below, default values are listed in parentheses.
Test names ("SYMBOLIC_TEST_NAME") can only contain alphanumerics/underscores, can not start with digit, and must be less than 128 characters.
The following options can be used in both site-wide ("local.cf") and user-specific ("user_prefs") configuration files to customize how SpamAssassin handles incoming email messages.
If only one valid score is listed, then that score is always used for a test.
If four valid scores are listed, then the score that is used depends on how SpamAssassin is being used. The first score is used when both Bayes and network tests are disabled (score set 0). The second score is used when Bayes is disabled, but network tests are enabled (score set 1). The third score is used when Bayes is enabled and network tests are disabled (score set 2). The fourth score is used when Bayes is enabled and network tests are enabled (score set 3).
Setting a rule's score to 0 will disable that rule from running.
If any of the score values are surrounded by parenthesis '()', then all of the scores in the line are considered to be relative to the already set score. ie: '(3)' means increase the score for this rule by 3 points in all score sets. '(3) (0) (3) (0)' means increase the score for this rule by 3 in score sets 0 and 2 only.
If no score is given for a test by the end of the configuration, a default score is assigned: a score of 1.0 is used for all tests, except those whose names begin with 'T_' (this is used to indicate a rule in testing) which receive 0.01.
Note that test names which begin with '__' are indirect rules used to compose meta-match rules and can also act as prerequisites to other rules. They are not scored or listed in the 'tests hit' reports, but assigning a score of 0 to an indirect rule will disable it from running.
Used to welcomelist sender addresses which send mail that is often tagged (incorrectly) as spam.
Use of this setting is not recommended, since it blindly trusts the message, which is routinely and easily forged by spammers and phish senders. The recommended solution is to instead use "welcomelist_auth" or other authenticated welcomelisting methods, or "welcomelist_from_rcvd".
Welcomelist and blocklist addresses are now file-glob-style patterns, so "friend@somewhere.com", "*@isp.com", or "*.domain.net" will all work. Specifically, "*" and "?" are allowed, but all other metacharacters are not. Regular expressions are not used for security reasons. Matching is case-insensitive.
Multiple addresses per line, separated by spaces, is OK. Multiple "welcomelist_from" lines are also OK.
The headers checked for welcomelist addresses are as follows: if "Resent-From" is set, use that; otherwise check all addresses taken from the following set of headers:
Envelope-Sender Resent-Sender X-Envelope-From From
In addition, the "envelope sender" data, taken from the SMTP envelope data where this is available, is looked up. See "envelope_sender_header".
e.g.
welcomelist_from joe@example.com fred@example.com welcomelist_from *@example.com
Used to remove a default welcomelist_from entry, so for example a distribution welcomelist_from can be overridden in a local.cf file, or an individual user can override a welcomelist_from entry in their own "user_prefs" file. The specified email address has to match exactly (although case-insensitively) the address previously used in a welcomelist_from line, which implies that a wildcard only matches literally the same wildcard (not 'any' address).
e.g.
unwelcomelist_from joe@example.com fred@example.com unwelcomelist_from *@example.com
Works similarly to welcomelist_from, except that in addition to matching a sender address, a relay's rDNS name or its IP address must match too for the welcomelisting rule to fire. The first parameter is a sender's e-mail address to welcomelist, and the second is a string to match the relay's rDNS, or its IP address. Matching is case-insensitive.
This second parameter is matched against a TCP-info information field as provided in a FROM clause of a trace information (i.e. in a Received header field, see RFC 5321). Only the Received header fields inserted by trusted hosts are considered. This parameter can either be a full hostname, or a domain component of that hostname, or an IP address (optionally followed by a slash and a prefix length) in square brackets. The address prefix (mask) length with a slash may stand within brackets along with an address, or may follow the bracketed address. Reverse DNS lookup is done by an MTA, not by SpamAssassin.
For backward compatibility as an alternative to a CIDR notation, an IPv4 address in brackets may be truncated on classful boundaries to cover whole subnets, e.g. "[10.1.2.3]", "[10.1.2]", "[10.1]", "[10]".
In other words, if the host that connected to your MX had an IP address 192.0.2.123 that mapped to 'sendinghost.example.org', you should specify "sendinghost.example.org", or "example.org", or "[192.0.2.123]", or "[192.0.2.0/24]", or "[192.0.2]" here.
Note that this requires that "internal_networks" be correct. For simple cases, it will be, but for a complex network you may get better results by setting that parameter.
It also requires that your mail exchangers be configured to perform DNS reverse lookups on the connecting host's IP address, and to record the result in the generated Received header field according to RFC 5321.
e.g.
welcomelist_from_rcvd joe@example.com example.com welcomelist_from_rcvd *@* mail.example.org welcomelist_from_rcvd *@axkit.org [192.0.2.123] welcomelist_from_rcvd *@axkit.org [192.0.2.0/24] welcomelist_from_rcvd *@axkit.org [192.0.2.0]/24 welcomelist_from_rcvd *@axkit.org [2001:db8:1234::/48] welcomelist_from_rcvd *@axkit.org [2001:db8:1234::]/48
Same as "welcomelist_from_rcvd", but used for the default welcomelist entries in the SpamAssassin distribution. The welcomelist score is lower, because these are often targets for spammer spoofing.
Specify addresses which are in "welcomelist_from_rcvd" that sometimes send through a mail relay other than the listed ones. By default mail with a From address that is in "welcomelist_from_rcvd" that does not match the relay will trigger a forgery rule. Including the address in "welcomelist_allows_relay" prevents that.
Welcomelist and blocklist addresses are now file-glob-style patterns, so "friend@somewhere.com", "*@isp.com", or "*.domain.net" will all work. Specifically, "*" and "?" are allowed, but all other metacharacters are not. Regular expressions are not used for security reasons. Matching is case-insensitive.
Multiple addresses per line, separated by spaces, is OK. Multiple "welcomelist_allows_relays" lines are also OK.
The specified email address does not have to match exactly the address previously used in a welcomelist_from_rcvd line as it is compared to the address in the header.
e.g.
welcomelist_allows_relays joe@example.com fred@example.com welcomelist_allows_relays *@example.com
Used to remove a default welcomelist_from_rcvd or def_welcomelist_from_rcvd entry, so for example a distribution welcomelist_from_rcvd can be overridden in a local.cf file, or an individual user can override a welcomelist_from_rcvd entry in their own "user_prefs" file.
The specified email address has to match exactly the address previously used in a welcomelist_from_rcvd line.
e.g.
unwelcomelist_from_rcvd joe@example.com fred@example.com unwelcomelist_from_rcvd *@axkit.org
Used to remove a default blocklist_from entry, so for example a distribution blocklist_from can be overridden in a local.cf file, or an individual user can override a blocklist_from entry in their own "user_prefs" file. The specified email address has to match exactly the address previously used in a blocklist_from line.
e.g.
unblocklist_from joe@example.com fred@example.com unblocklist_from *@spammer.com
If the given address appears as a recipient in the message headers (Resent-To, To, Cc, obvious envelope recipient, etc.) the mail will be listed as allowed. Useful if you're deploying SpamAssassin system-wide, and don't want some users to have their mail filtered. Same format as "welcomelist_from".
There are three levels of To-welcomelisting, "welcomelist_to", "more_spam_to" and "all_spam_to". Users in the first level may still get some spammish mails blocked, but users in "all_spam_to" should never get mail blocked.
The headers checked for welcomelist addresses are as follows: if "Resent-To" or "Resent-Cc" are set, use those; otherwise check all addresses taken from the following set of headers:
To Cc Apparently-To Delivered-To Envelope-Recipients Apparently-Resent-To X-Envelope-To Envelope-To X-Delivered-To X-Original-To X-Rcpt-To X-Real-To
If the given address appears as a recipient in the message headers (Resent-To, To, Cc, obvious envelope recipient, etc.) the mail will be blocklisted. Same format as "blocklist_from".
Used to specify addresses which send mail that is often tagged (incorrectly) as spam. This is different from "welcomelist_from" and "welcomelist_from_rcvd" in that it first verifies that the message was sent by an authorized sender for the address, before welcomelisting.
Authorization is performed using one of the installed sender-authorization schemes: SPF (using "Mail::SpamAssassin::Plugin::SPF"), or DKIM (using "Mail::SpamAssassin::Plugin::DKIM"). Note that those plugins must be active, and working, for this to operate.
Using "welcomelist_auth" is roughly equivalent to specifying duplicate "welcomelist_from_spf", "welcomelist_from_dk", and "welcomelist_from_dkim" lines for each of the addresses specified.
e.g.
welcomelist_auth joe@example.com fred@example.com welcomelist_auth *@example.com
Same as "welcomelist_auth", but used for the default welcomelist entries in the SpamAssassin distribution. The welcomelist score is lower, because these are often targets for spammer spoofing.
Used to remove a "welcomelist_auth" or "def_welcomelist_auth" entry. The specified email address has to match exactly the address previously used.
e.g.
unwelcomelist_auth joe@example.com fred@example.com unwelcomelist_auth *@example.com
Host names may optionally be prefixed by an exclamation mark '!', which produces false as a result if this entry matches. This makes it easier to exclude some subdomains when their superdomain is listed, for example:
enlist_uri_host (MYLIST) !sub1.example.com !sub2.example.com example.com
No wildcards are supported, but subdomains do match implicitly. Lists are independent. Search for each named list starts by looking up the full hostname first, then leading fields are progressively stripped off (e.g.: sub.example.com, example.com, com) until a match is found or we run out of fields. The first matching entry (the most specific) determines if a lookup yielded a true (no '!' prefix) or a false (with a '!' prefix) result.
If an URL found in a message contains an IP address in place of a host name, the given list must specify the exact same IP address (instead of a host name) in order to match.
Use the delist_uri_host directive to neutralize previous enlist_uri_host settings.
Enlisting to lists named 'BLOCK' and 'WELCOME' have their shorthand directives blocklist_uri_host and welcomelist_uri_host and corresponding default rules, but the names 'BLOCK' and 'WELCOME' are otherwise not special or reserved.
Note that directives in configuration files are processed in sequence, the delist_uri_host only applies to previously listed entries and has no effect on enlisted entries in yet-to-be-processed directives.
For convenience (similarity to the enlist_uri_host directive) hostnames may be prefixed by a an exclamation mark, which is stripped off from each name and has no meaning here.
Listed addresses are file-glob-style patterns, so "friend@somewhere.com", "*@isp.com", or "*.domain.net" will all work. Specifically, "*" and "?" are allowed, but all other metacharacters are not. Regular expressions are not used for security reasons. Matching is case-insensitive.
Multiple addresses per line, separated by spaces, is OK. Multiple "enlist_addrlist" lines are also OK.
Enlisting an address to the list named blocklist_to is synonymous to using the directive blocklist_to.
Enlisting an address to the list named blocklist_from is synonymous to using the directive blocklist_from.
Enlisting an address to the list named welcomelist_to is synonymous to using the directive welcomelist_to.
Enlisting an address to the list named welcomelist_from is synonymous to using the directive welcomelist_from.
e.g.
enlist_addrlist (PAYPAL_ADDRESS) service@paypal.com enlist_addrlist (PAYPAL_ADDRESS) *@paypal.co.uk
Is a shorthand for a directive: enlist_uri_host (BLOCK) host ...
Please see directives enlist_uri_host and delist_uri_host for details.
Is a shorthand for a directive: enlist_uri_host (WELCOME) host ...
Please see directives enlist_uri_host and delist_uri_host for details.
Parentheses are not permitted in STRING if rewriting the From or To headers. (They will be converted to square brackets.)
If "rewrite_header subject" is used, but the message being rewritten does not already contain a "Subject" header, one will be created.
A null value for "STRING" will remove any existing rewrite for the specified header.
The check "if can(Mail::SpamAssassin::Conf::feature_subjprefix)" should be used to silence warnings in previous SpamAssassin versions.
To be able to use this feature a "add_header all Subjprefix _SUBJPREFIX_" configuration line could be needed when the glue between the MTA and SpamAssassin rewrites the email content.
Here is an example on how to use this feature:
rewrite_header Subject *****SPAM***** add_header all Subjprefix _SUBJPREFIX_ body OLEMACRO_MALICE eval:check_olemacro_malice() describe OLEMACRO_MALICE Dangerous Office Macro score OLEMACRO_MALICE 5.0 if can(Mail::SpamAssassin::Conf::feature_subjprefix) subjprefix OLEMACRO_MALICE [VIRUS] endif
The order of "add_header" configuration options is preserved, inserted headers will follow this order of declarations. When combining "add_header" with "clear_headers" and "remove_header", keep in mind that "add_header" appends a new header to the current list, after first removing any existing header fields of the same name. Note also that "add_header", "clear_headers" and "remove_header" may appear in multiple .cf files, which are interpreted in alphabetic order.
"string" can contain tags as explained below in the TEMPLATE TAGS section. You can also use "\n" and "\t" in the header to add newlines and tabulators as desired. A backslash has to be written as \\, any other escaped chars will be silently removed.
All headers will be folded if fold_headers is set to 1. Note: Manually adding newlines via "\n" disables any further automatic wrapping (ie: long header lines are possible). The lines will still be properly folded (marked as continuing) though.
You can customize existing headers with add_header (only the specified subset of messages will be changed).
See also "clear_headers" and "remove_header" for removing headers.
Here are some examples (these are the defaults, note that Checker-Version can not be changed or removed):
add_header spam Flag _YESNOCAPS_ add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_ add_header all Level _STARS(*)_ add_header all Checker-Version SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_
See also "clear_headers" for removing all the headers at once.
Note that X-Spam-Checker-Version is not removable because the version information is needed by mail administrators and developers to debug problems. Without at least one header, it might not even be possible to determine that SpamAssassin is running.
"add_header", "clear_headers" and "remove_header" may appear in multiple .cf files, which are interpreted in alphabetic order, so "clear_headers" in a later file will remove all added headers from previously interpreted configuration files, which may or may not be desired.
Note that X-Spam-Checker-Version is not removable because the version information is needed by mail administrators and developers to debug problems. Without at least one header, it might not even be possible to determine that SpamAssassin is running.
If this option is set to 2, then original messages will be attached with a content type of text/plain instead of message/rfc822. This setting may be required for safety reasons on certain broken mail clients that automatically load attachments without any action by the user. This setting may also make it somewhat more difficult to extract or view the original message.
If this option is set to 0, incoming spam is only modified by adding some "X-Spam-" headers and no changes will be made to the body. In addition, a header named X-Spam-Report will be added to spam. You can use the remove_header option to remove that header after setting report_safe to 0.
See report_safe_copy_headers if you want to copy headers from the original mail into tagged messages.
If you receive lots of spam in foreign languages, and never get any non-spam in these languages, this may help. Note that all ISO-8859-* character sets, and Windows code page character sets, are always permitted by default.
Set this to "all" to allow all character sets. This is the default.
The rules "CHARSET_FARAWAY", "CHARSET_FARAWAY_BODY", and "CHARSET_FARAWAY_HEADERS" are triggered based on how this is set.
Examples:
ok_locales all (allow all locales) ok_locales en (only allow English) ok_locales en ja zh (allow English, Japanese, and Chinese)
Note: if there are multiple ok_locales lines, only the last one is used.
Select the locales to allow from the list below:
Unicode support in old versions of perl or in a core module Encode is likely to be buggy in places, so if the normalize_charset function is enabled it is advised to stick to more recent versions of perl (preferably 5.12 or later). The module Encode::Detect::Detector is optional, when necessary it will be used if it is available.
See "https://wiki.apache.org/spamassassin/TrustPath" for more information.
MXes for your domain(s) and internal relays should also be specified using the "internal_networks" setting. When there are 'trusted' hosts that are not MXes or internal relays for your domain(s) they should only be specified in "trusted_networks".
The "IPaddress" can be an IPv4 address (in a dot-quad form), or an IPv6 address optionally enclosed in square brackets. Scoped link-local IPv6 addresses are syntactically recognized but the interface scope is currently ignored (e.g. [fe80::1234%eth0] ) and should be avoided.
If a "/masklen" is specified, it is considered a CIDR-style 'netmask' length, specified in bits. If it is not specified, but less than 4 octets of an IPv4 address are specified with a trailing dot, an implied netmask length covers all addresses in remaining octets (i.e. implied masklen is /8 or /16 or /24). If masklen is not specified, and there is not trailing dot, then just a single IP address specified is used, as if the masklen were "/32" with an IPv4 address, or "/128" in case of an IPv6 address.
If module Net::CIDR::Lite is installed, it's also possible to use dash separated IP range format (e.g. 192.168.1.1-192.168.255.255).
If a network or host address is prefaced by a "!" the matching network or host will be excluded from the list even if a less specific (shorter netmask length) subnet is later specified in the list. This allows a subset of a wider network to be exempt. In case of specifying overlapping subnets, specify more specific subnets first (tighter matching, i.e. with a longer netmask length), followed by less specific (shorter netmask length) subnets to get predictable results regardless of the search algorithm used - when Net::Patricia module is installed the search finds the tightest matching entry in the list, while a sequential search as used in absence of the module Net::Patricia will find the first matching entry in the list.
Note: 127.0.0.0/8 and ::1 are always included in trusted_networks, regardless of your config.
Examples:
trusted_networks 192.168.0.0/16 # all in 192.168.*.* trusted_networks 192.168. # all in 192.168.*.* trusted_networks 212.17.35.15 # just that host trusted_networks !10.0.1.5 10.0.1/24 # all in 10.0.1.* but not 10.0.1.5 trusted_networks 2001:db8:1::1 !2001:db8:1::/64 2001:db8::/32 # 2001:db8::/32 and 2001:db8:1::1/128, except the rest of 2001:db8:1::/64
This operates additively, so a "trusted_networks" line after another one will append new entries to the list of trusted networks. To clear out the existing entries, use "clear_trusted_networks".
If "trusted_networks" is not set and "internal_networks" is, the value of "internal_networks" will be used for this parameter.
If neither "trusted_networks" or "internal_networks" is set, a basic inference algorithm is applied. This works as follows:
This value is used when checking 'dial-up' or dynamic IP address blocklists, in order to detect direct-to-MX spamming.
Trusted relays that accept mail directly from dial-up connections (i.e. are also performing a role of mail submission agents - MSA) should not be listed in "internal_networks". List them only in "trusted_networks".
If "trusted_networks" is set and "internal_networks" is not, the value of "trusted_networks" will be used for this parameter.
If neither "trusted_networks" nor "internal_networks" is set, no addresses will be considered local; in other words, any relays past the machine where SpamAssassin is running will be considered external.
Every entry in "internal_networks" must appear in "trusted_networks"; in other words, "internal_networks" is always a subset of the trusted set.
Note: 127/8 and ::1 are always included in internal_networks, regardless of your config.
MSA means that the relay hosts on these networks accept mail from your own users and authenticates them appropriately. These relays will never accept mail from hosts that aren't authenticated in some way. Examples of authentication include, IP lists, SMTP AUTH, POP-before-SMTP, etc.
All relays found in the message headers after the MSA relay will take on the same trusted and internal classifications as the MSA relay itself, as defined by your trusted_networks and internal_networks configuration.
For example, if the MSA relay is trusted and internal so will all of the relays that precede it.
When using msa_networks to identify an MSA it is recommended that you treat that MSA as both trusted and internal. When an MSA is not included in msa_networks you should treat the MSA as trusted but not internal, however if the MSA is also acting as an MX or intermediate relay you must always treat it as both trusted and internal and ensure that the MSA includes visible auth tokens in its Received header to identify submission clients.
Warning: Never include an MSA that also acts as an MX (or is also an intermediate relay for an MX) or otherwise accepts mail from non-authenticated users in msa_networks. Doing so will result in unknown external relays being trusted.
These IP addresses are virtually appended into the Received: chain, so they are used in RBL checks where appropriate.
Currently the IP addresses are not added into X-Spam-Relays-* header fields, but they may be in the future.
By default, SpamAssassin will run RBL checks. Individual blocklists may be disabled selectively by setting a score of a corresponding rule to 0.
See also a related configuration parameter skip_uribl_checks, which controls the URIDNSBL plugin (documented in the URIDNSBL man page).
When the option value is a test (with or without arguments), SpamAssassin will query some domain names on the internet during initialization, attempting to determine if DNS resolving is working or not. A space-separated list of domain names may be specified explicitly, or left to a built-in default of a dozen or so domain names. From an explicit or a default list a subset of three domain names is picked randomly for checking. The test queries for NS records of these domain: if at least one query returns a success then SpamAssassin considers DNS resolving as available, otherwise not.
The problem is that the test can introduce some startup delay if a network connection is down, and in some cases it can wrongly guess that DNS is unavailable because a test connection failed, what causes disabling several DNS-dependent tests.
Please note, the DNS test queries for NS records, so specify domain names, not host names.
Since version 3.4.0 of SpamAssassin a default setting for option dns_available is yes. A default in older versions was test.
Examples :
dns_server 127.0.0.1
dns_server 127.0.0.1:53
dns_server [127.0.0.1]:53
dns_server [::1]:53
dns_server fe80::1%lo0
dns_server [fe80::1%lo0]:53
In absence of dns_server directives, the list of name servers is provided by Net::DNS module, which typically obtains the list from /etc/resolv.conf, but this may be platform dependent. Please consult the Net::DNS::Resolver documentation for details.
The argument is a whitespace-separated or a comma-separated list of single port numbers n, or port number pairs (i.e. m-n) delimited by a '-', representing a range. Allowed port numbers are between 1 and 65535.
Directives dns_local_ports_permit and dns_local_ports_avoid are processed in order in which they appear in configuration files. Each directive adds (or subtracts) its subsets of ports to a current set of available ports. Whatever is left in the set by the end of configuration processing is made available to a DNS resolving client code.
If the resulting set of port numbers is empty (see also the directive dns_local_ports_none), then SpamAssassin does not apply its ports randomization logic, but instead leaves the operating system to choose a suitable free local port number.
The initial set consists of all port numbers in the range 1024-65535. Note that system config files already modify the set and remove all the IANA registered port numbers and some other ranges, so there is rarely a need to adjust the ranges by site-specific directives.
See also directives dns_local_ports_permit and dns_local_ports_none.
Please see directive dns_local_ports_permit for details.
dns_local_ports_avoid 1-65535
leaving the set of available DNS query local port numbers empty. In all respects (apart from speed) it is equivalent to the shown directive, and can be freely mixed with dns_local_ports_permit and dns_local_ports_avoid.
If the resulting set of port numbers is empty, then SpamAssassin does not apply its ports randomization logic, but instead leaves the operating system to choose a suitable free local port number.
See also directives dns_local_ports_permit and dns_local_ports_avoid.
Option v4 declares resolver capable of returning IPv4 (A) records. Option v6 declares resolver capable of returning IPv6 (AAAA) records. One would set nov6 if the resolver is filtering AAAA responses. NOTE: these options only refer to resolving capabilies, there is no other meaning like whether the IP address of resolver itself is IPv4 or IPv6.
Option edns (or edns0) may take a value which specifies a requestor's acceptable UDP payload size according to EDNS0 specifications (RFC 6891, ex RFC 2671) e.g. edns=4096. When EDNS0 is off (noedns or edns=512) a traditional implied UDP payload size is 512 bytes, which is also a minimum allowed value for this option. When the option is specified but a value is not provided, a conservative default of 1220 bytes is implied. It is recommended to keep edns enabled when using a local recursive DNS server which supports EDNS0 (like most modern DNS servers do), a suitable setting in this case is edns=4096, which is also a default. Allowing UDP payload size larger than 512 bytes can avoid truncation of resource records in large DNS responses (like in TXT records of some SPF and DKIM responses, or when an unreasonable number of A records is published by some domain). The option should be disabled when a recursive DNS server is only reachable through non- RFC 6891 compliant middleboxes (such as some old-fashioned firewall) which bans DNS UDP payload sizes larger than 512 bytes. A suitable value when a non-local recursive DNS server is used and a middlebox does allow EDNS0 but blocks fragmented IP packets is perhaps 1220 bytes, allowing a DNS UDP packet to fit within a single IP packet in most cases (a slightly less conservative range would be 1280-1410 bytes).
Option rotate causes SpamAssassin to choose a DNS server at random from all servers listed in "/etc/resolv.conf" every dns_test_interval seconds, effectively spreading the load over all currently available DNS servers when there are many spamd workers.
Option dns0x20 enables randomization of letters in a DNS query label according to draft-vixie-dnsext-dns0x20, decreasing a chance of collisions of responses (by chance or by a malicious intent) by increasing spread as provided by a 16-bit query ID and up to 16 bits of a port number, with additional bits as encoded by flipping case (upper/lower) of letters in a query. The number of additional random bits corresponds to the number of letters in a query label. Should work reliably with all mainstream DNS servers - do not turn on if you see frequent info messages "dns: no callback for id:" in the log, or if RBL or URIDNS lookups do not work for no apparent reason.
Most DNS queries (with some exceptions) are subject to dns_query_restriction. A domain to be queried is successively stripped-off of its leading labels (thus yielding a series of its parent domains), and on each iteration a check is made against an associative array generated by dns_query_restriction options. Search stops at the first match (i.e. the tightest match), and the matching entry with its "allow" or "deny" value then controls whether a DNS query is allowed to be launched.
If no match is found an implicit default is to allow a query. The purpose of an explicit "allow" entry is to be able to override a previously configured "deny" on the same domain or to override an entry (possibly yet to be configured in subsequent config directives) on one of its parent domains. Thus an 'allow zen.spamhaus.org' with a 'deny spamhaus.org' would permit DNS queries on a specific DNS BL zone but deny queries to other zones under the same parent domain.
Domains are matched case-insensitively, no wildcards are recognized, there should be no leading or trailing dot.
Specifying a block on querying a domain name has a similar effect as setting a score of corresponding DNSBL and URIBL rules to zero, and can be a handy alternative to hunting for such rules when a site policy does not allow certain DNS block lists to be queried.
Special wildcard "dns_query_restriction deny *" is supported to block all queries except allowed ones.
Example:
dns_query_restriction deny dnswl.org surbl.org
dns_query_restriction allow zen.spamhaus.org
dns_query_restriction deny spamhaus.org mailspike.net spamcop.net
urirhssub URIBL_BLOCKED multi.uribl.com. A 1 dns_block_rule URIBL_BLOCKED multi.uribl.com
Block status is maintained across all processes by empty statefile named "dnsblock_multi.uribl.com" in global state dir: home_dir_for_helpers/.spamassassin, $HOME/.spamassassin, /var/lib/spamassassin (localstate), depending which is found and writable.
See the documentation for the "Mail::SpamAssassin::Plugin::AutoLearnThreshold" plugin module for details on how Bayes auto-learning is implemented by default.
The default set is: header visible invisible uri, which is equivalent for example to: All NoMIMEpart. The reason why mimepart is not currently in a default set is that it is a newer source (introduced with SpamAssassin version 3.4.1) and not much experience has yet been gathered regarding its usefulness.
See also option "bayes_ignore_header" for a fine-grained control on individual header fields under the umbrella of a more general keyword header here.
Keywords imply the following data sources:
The "bayes_token_sources" directive may appear multiple times, its keywords are interpreted sequentially, adding or removing items from the final set as they appear in their order in "bayes_token_sources" directive(s).
bayes_ignore_header X-Upstream-Spamfilter bayes_ignore_header X-Upstream-SomethingElse
Spam messages from certain senders may contain many words that frequently occur in ham. For example, one might read messages from a preferred bookstore but also get unwanted spam messages from other bookstores. If the unwanted messages are learned as spam then any messages discussing books, including the preferred bookstore and antiquarian messages would be in danger of being marked as spam. The addresses of the annoying bookstores would be listed. (Assuming they were halfway legitimate and didn't send you mail through myriad affiliates.)
Those who have pieces of spam in legitimate messages or otherwise receive ham messages containing potentially spammy words might fear that some spam messages might be in danger of being marked as ham. The addresses of the spam mailing lists, correspondents, etc. would be listed.
If this options is set the BayesStore::SQL module will override the set username with the value given. This could be useful for implementing global or group bayes databases.
If bayes_auto_expire is true and a Bayes datastore backend supports it (currently only Redis), this setting controls deletion of expired tokens from a bayes database. The value is observed on a best-effort basis, exact timing promises are not necessarily kept. If a bayes datastore backend does not implement individual key/value expirations, the setting is silently ignored.
If bayes_auto_expire is true and a Bayes datastore backend supports it (currently only Redis), this setting controls deletion of expired 'seen' entries from a bayes database. The value is observed on a best-effort basis, exact timing promises are not necessarily kept. If a bayes datastore backend does not implement individual key/value expirations, the setting is silently ignored.
This is a best-effort advisory setting, processing will not be abruptly aborted at an arbitrary point in processing when the time limit is exceeded, but only on reaching one of locations in the program flow equipped with a time test. Currently equipped with the test are the main checking loop, asynchronous DNS lookups, plugins which are calling external programs. Rule evaluation is guarded by starting a timer (alarm) on each set of compiled rules.
When a message is passed to Mail::SpamAssassin::parse, a deadline time is established as a sum of current time and the "time_limit" setting.
This deadline may also be specified by a caller through an option 'master_deadline' in $suppl_attrib on a call to parse(), possibly providing a more accurate deadline taking into account past and expected future processing of a message in a mail filtering setup. If both the config option as well as a 'master_deadline' option in a call are provided, the shorter time limit of the two is used (since version 3.3.2). Note that spamd (and possibly third-party callers of SpamAssassin) will supply the 'master_deadline' option in a call based on its --timeout-child option (or equivalent), unlike the command line "spamassassin", which has no such command line option.
When a time limit is exceeded, most of the remaining tests will be skipped, as well as auto-learning. Whatever tests fired so far will determine the final score. The behaviour is similar to short-circuiting with attribute 'on', as implemented by a Shortcircuit plugin. A synthetic hit on a rule named TIME_LIMIT_EXCEEDED with a near-zero default score is generated, so that the report will reflect the event. A score for TIME_LIMIT_EXCEEDED may be provided explicitly in a configuration file, for example to achieve welcomelisting or blocklisting effect for messages with long processing times.
The "time_limit" option is a useful protection against excessive processing time on certain degenerate or unusually long or complex mail messages, as well as against some DoS attacks. It is also needed in time-critical pre-queue filtering setups (e.g. milter, proxy, integration with MTA), where message processing must finish before a SMTP client times out. RFC 5321 prescribes in section 4.5.3.2.6 the 'DATA Termination' time limit of 10 minutes, although it is not unusual to see some SMTP clients abort sooner on waiting for a response. A sensible "time_limit" for a pre-queue filtering setup is maybe 50 seconds, assuming that clients are willing to wait at least a minute.
This will be quite a bit faster, but may risk file corruption if the files are ever accessed by multiple clients at once, and one or more of them is accessing them through an NFS filesystem.
Note that different platforms require different locking systems.
The supported locking systems for "type" are as follows:
nfssafe and flock are only available on UNIX, and win32 is only available on Windows. By default, SpamAssassin will choose either nfssafe or win32 depending on the platform in use.
The automatic wrapping can be disabled here. Note that this can generate very long lines. RFC 2822 required that header lines do not exceed 998 characters (not counting the final CRLF).
By default, various MTAs will use different headers, such as the following:
X-Envelope-From Envelope-Sender X-Sender Return-Path
SpamAssassin will attempt to use these, if some heuristics (such as the header placement in the message, or the absence of fetchmail signatures) appear to indicate that they are safe to use. However, it may choose the wrong headers in some mailserver configurations. (More discussion of this can be found in bug 2142 and bug 4747 in the SpamAssassin BugZilla.)
To avoid this heuristic failure, the "envelope_sender_header" setting may be helpful. Name the header that your MTA or MDA adds to messages containing the address used at the MAIL FROM step of the SMTP transaction.
If the header in question contains "<" or ">" characters at the start and end of the email address in the right-hand side, as in the SMTP transaction, these will be stripped.
If the header is not found in a message, or if it's value does not contain an "@" sign, SpamAssassin will issue a warning in the logs and fall back to its default heuristics.
(Note for MTA developers: we would prefer if the use of a single header be avoided in future, since that precludes 'downstream' spam scanning. "https://wiki.apache.org/spamassassin/EnvelopeSenderInReceived" details a better proposal, storing the envelope sender at each hop in the "Received" header.)
example:
envelope_sender_header X-SA-Exim-Mail-From
Note that test names which begin with '__' are reserved for meta-match sub-rules, and are not scored or listed in the 'tests hit' reports.
Also note that by convention, rule descriptions should be limited in length to no more than 50 characters.
If you change this, try to keep it under 78 columns. Each "report" line appends to the existing template, so use "clear_report_template" to restart.
Tags can be included as explained above.
Each "unsafe-report" line appends to the existing template, so use "clear_unsafe_report_template" to restart.
Tags can be used in this template (see above for details).
For example, this setting will allow sa-learn to process emails stored in a kmail 2 mbox:
mbox_format_from_regex /^From \S+ ?[[:upper:]][[:lower:]]{2}(?:, \d\d [[:upper:]][[:lower:]]{2} \d{4} [0-2]\d:\d\d:\d\d [+-]\d{4}| [[:upper:]][[:lower:]]{2} [ 1-3]\d [ 0-2]\d:\d\d:\d\d \d{4})/
These settings differ from the ones above, in that they are considered 'privileged'. Only users running "spamassassin" from their procmailrc's or forward files, or sysadmins editing a file in "/etc/spamassassin", can use them. "spamd" users cannot use them in their "user_prefs" files, for security and efficiency reasons, unless "allow_user_rules" is enabled (and then, they may only add rules from below).
Note that it is not currently possible to use "allow_user_rules" to modify an existing system rule from a "user_prefs" file with "spamd".
Note: The target URI portion must be surrounded in parentheses
and
no other part of the pattern may create a backreference.
Example: http://chkpt.zdnet.com/chkpt/whatever/spammer.domain/yo/dude
redirector_pattern /^https?:\/\/(?:opt\.)?chkpt\.zdnet\.com\/chkpt\/\w+\/(.*)$/i
Appending a modifier ":raw" to a header field name will inhibit decoding of quoted-printable or base-64 encoded strings, and will preserve all whitespace inside the header string. The ":raw" may also be applied to pseudo-headers e.g. "ALL:raw" will return a pristine (unmodified) header section.
Appending a modifier ":addr" to a header field name will cause everything except the first email address to be removed from the header field. It is mainly applicable to header fields 'From', 'Sender', 'To', 'Cc' along with their 'Resent-*' counterparts, and the 'Return-Path'.
Appending a modifier ":name" to a header field name will cause everything except the first display name to be removed from the header field. It is mainly applicable to header fields containing a single mail address: 'From', 'Sender', along with their 'Resent-From' and 'Resent-Sender' counterparts.
It is syntactically permitted to append more than one modifier to a header field name, although currently most combinations achieve no additional effect, for example "From:addr:raw" or "From:raw:addr" is currently the same as "From:addr" .
For example, appending ":addr" to a header name will result in example@foo in all of the following cases:
For example, appending ":name" to a header name will result in "Foo Blah" (without quotes) in all of the following cases:
There are several special pseudo-headers that can be specified:
"op" is either "=~" (contains regular expression) or "!~" (does not contain regular expression), and "pattern" is a valid Perl regular expression, with "modifiers" as regexp modifiers in the usual style. Note that multi-line rules are not supported, even if you use "x" as a modifier. Also note that the "#" character must be escaped ("\#") or else it will be considered to be the start of a comment and not part of the regexp.
If the header specified matches multiple headers, their text will be concatenated with embedded \n's. Therefore you may wish to use "/m" if you use "^" or "$" in your regular expression.
If the "[if-unset: STRING]" tag is present, then "STRING" will be used if the header is not found in the mail message.
Test names must not start with a number, and must contain only alphanumerics and underscores. It is suggested that lower-case characters not be used, and names have a length of no more than 22 characters, as an informal convention. Dashes are not allowed.
Note that test names which begin with '__' are reserved for meta-match sub-rules, and are not scored or listed in the 'tests hit' reports. Test names which begin with 'T_' are reserved for tests which are undergoing QA, and these are given a very low score.
If you add or modify a test, please be sure to run a sanity check afterwards by running "spamassassin --lint". This will avoid confusing error messages, or other tests being skipped as a side-effect.
Also, if more than one IP address gets a DNSBL hit for a particular rule, it does not affect the score because rules only trigger once per message.
The domain name is considered to be a fully qualified domain name (i.e. not subject to DNS resolver's search or default domain options). No trailing period is needed, and will be removed if specified.
Note that this requires that SpamAssassin know which relays are trusted. For simple cases, SpamAssassin can make a good estimate. For complex cases, you may get better results by setting "trusted_networks" manually.
In addition, you can test all untrusted IP addresses by placing '-untrusted' at the end of the set name. Important note -- this does NOT include the IP address from the most recent 'untrusted line', as used in '-firsttrusted' above. That's because we're talking about the trustworthiness of the IP address data, not the source header line, here; and in the case of the most recent header (the 'firsttrusted'), that data can be trusted. See the Wiki page at "https://wiki.apache.org/spamassassin/TrustedRelays" for more information on this.
Note: the set name must be exactly the same for as the main query rule, including selections like '-notfirsthop' appearing at the end of the set name.
The 'body' in this case is the textual parts of the message body; any non-text MIME parts are stripped, and the message decoded from Quoted-Printable or Base-64-encoded format if necessary. Parts declared as text/html will be rendered from HTML to text.
Body is processed as a raw byte string, which means Unicode-specific regex features like \p{} can NOT be used for matching. The normalize_charset setting will also affect how raw bytes are presented. Rules in .cf files should be written portably - to match "a with umlaut" character, look for both LATIN1 and UTF8 raw byte variants: /(?:\xE4|\xC3\xA4)/
All body paragraphs (double-newline-separated blocks text) are turned into a linebreaks-removed, whitespace-normalized, single line. Any lines longer than 2kB are split into shorter separate lines (from a boundary when possible), this may unexpectedly prevent pattern from matching. Patterns are matched independently against each of these lines.
Note that by default the message Subject header is considered part of the body and becomes the first line when running the rules. If you don't want to match Subject along with body text, use "tflags RULENAME nosubject".
See "https://wiki.apache.org/SpamAssassin/WritingRules" for more information.
The 'uri' in this case is a list of all the URIs in the body of the email, and the test will be run on each and every one of those URIs, adjusting the score if a match is found. Use this test instead of one of the body tests when you need to match a URI, as it is more accurately bound to the start/end points of the URI, and will also be faster.
The 'raw body' of a message is the raw data inside all textual parts. The text will be decoded from base64 or quoted-printable encoding, but HTML tags and line breaks will still be present. Multiline expressions will need to be used to match strings that are broken by line breaks.
Note that the text is split into 2-4kB chunks (from a word boundary when possible), this may unexpectedly prevent pattern from matching. Patterns are matched independently against each of these chunks.
The full message is the pristine message headers plus the pristine message body, including all MIME data such as images, other attachments, MIME boundaries, etc.
Note that CRLF/LF line endings are matched as the original message has them. For any full rules that match newlines, it's recommended to use \r?$ instead of plain $, so it works on all systems.
meta META1 TEST1 && !(TEST2 || TEST3)
Note that English language operators ("and", "or") will be treated as rule names, and that there is no "XOR" operator.
For example:
meta META2 (3 * TEST1 - 2 * TEST2) > 0
Note that Perl builtins and functions, like abs(), can't be used, and will be treated as rule names.
If you want to define a meta-rule, but do not want its individual sub-rules to count towards the final score unless the entire meta-rule matches, give the sub-rules names that start with '__' (two underscores). SpamAssassin will ignore these for scoring.
For example, this will hit if at least two __FOO_* rule hits:
body __FOO_1 /xxx/ body __FOO_2 /yyy/ body __FOO_3 /zzz/ meta FOO_META rules_matching(__FOO_*) >= 2
Which would be the same as:
meta FOO_META (__FOO_1 + __FOO_2 + __FOO_3) >= 2
"reuse SPF_PASS"
"reuse MY_NET_RULE_V2 MY_NET_RULE_V1"
The actual logic for reuse tests is done by Mail::SpamAssassin::Plugin::Reuse.
Normally, SpamAssassin will require 3 points from the header and 3 points from the body to be auto-learned as spam. This option keeps the threshold at 6 points total but changes it to have no regard to the source of the points.
Normally, AWL plugin normalizes scores via auto-welcomelist. In some scenarios it works against the system administrator when trying to add some rules to correct miss-classified email. When AWL plugin searches the email and finds the noawl flag it will exit without normalizing the score nor storing the value in db.
For example:
uri __KAM_COUNT_URIS /^./ tflags __KAM_COUNT_URIS multiple maxhits=16 describe __KAM_COUNT_URIS A multiple match used to count URIs in a message meta __KAM_HAS_0_URIS (__KAM_COUNT_URIS == 0) meta __KAM_HAS_1_URIS (__KAM_COUNT_URIS >= 1) meta __KAM_HAS_2_URIS (__KAM_COUNT_URIS >= 2) meta __KAM_HAS_3_URIS (__KAM_COUNT_URIS >= 3) meta __KAM_HAS_4_URIS (__KAM_COUNT_URIS >= 4) meta __KAM_HAS_5_URIS (__KAM_COUNT_URIS >= 5) meta __KAM_HAS_10_URIS (__KAM_COUNT_URIS >= 10) meta __KAM_HAS_15_URIS (__KAM_COUNT_URIS >= 15)
The values -99999999999999 and -99999999999998 have a special meaning internally, and should not be used.
SpamAssassin 4.0 supports capturing template tags from regex rules. The captured tags, along with other standard template tags, can be used in other rules as a matching string. See TEMPLATE TAGS section for more info on tags.
Capturing can be done in any body/rawbody/header/uri/full rule that uses a regex for matching (not eval rules). Standard Perl named capture group format "(?<NAME>pattern)" must be used, as described in <https://perldoc.perl.org/perlre#(?%3CNAME%3Epattern)>.
Example, capturing a tag named "BODY_HELLO_NAME":
body __HELLO_NAME /\bHello, (?<BODY_HELLO_NAME>\w+)\b/
The tag can then be used in another rule for matching, using a %{TAGNAME} template. This would search the captured name in From-header:
header HELLO_NAME_IN_FROM From =~ /\b%{BODY_HELLO_NAME}\b/i
If any tag that a rule depends on is not found, then the rule is not run at all. To prevent a literal %{NAME} string from being parsed as a template, it can be escaped with a backslash: \%{NAME}.
Captured tags can also be used in reports and in other plugins like AskDNS, with the standard "_BODY_HELLO_NAME_" notation.
Note that at this time there is no automatic dependency tracking for rule running order. All rules that use named capture groups are automatically set to priority -10000, so that the tags should always be ready for any normal rules to use. When rule depends on a tag that might be set at later stage by a plugin for example, it's priority should be set manually to a higher value.
These settings differ from the ones above, in that they are considered 'more privileged' -- even more than the ones in the PRIVILEGED SETTINGS section. No matter what "allow_user_rules" is set to, these can never be set from a user's "user_prefs" file when spamc/spamd is being used. However, all settings can be used by local programs run directly by the user.
The version_tag will be lowercased, and any non-alphanumeric or period character will be replaced by an underscore.
e.g.
version_tag myrules1 # version=2.41-myrules1
These tests are only run as part of the test suite - they should not affect the general running of SpamAssassin.
queries left 100% 90% 80% 70% 60% 50% 40% 30% 20% 10% 0% timeout 15 14.9 14.5 13.9 13.1 12.0 10.7 9.1 7.3 5.3 3
For example, if 20 queries are made at the beginning of a message check and 16 queries have returned (leaving 20%), the remaining 4 queries should finish within 7.3 seconds since their query started or they will be timed out. Note that timed out queries are only aborted when there is nothing else left for SpamAssassin to do - long evaluation of other rules may grant queries additional time.
If a parameter 'zone' is specified (it must end with a letter, which distinguishes it from other numeric parametrs), then the setting only applies to DNS queries against the specified DNS domain (host, domain or RBL (sub)zone). Matching is case-insensitive, the actual domain may be a subdomain of the specified zone.
By default, each user has their own in their "~/.spamassassin" directory with mode 0700/0600. For system-wide SpamAssassin use, you may want to reduce disk space usage by sharing this across all users. However, Bayes appears to be more effective with individual user databases.
Make sure you specify this using the 'x' mode bits set, as it may also be used to create directories. However, if a file is created, the resulting file will not have any execute bits set (the umask is set to 111). The argument is a string of octal digits, it is converted to a numeric value internally.
This option give the connect string used to connect to the SQL based Bayes storage.
This option gives the username used by the above DSN.
This option gives the password used by the above DSN.
NOTE: By default the user is considered invalid until a plugin returns a true value. If you enable this, but do not have a proper plugin loaded, all users will turn up as invalid.
The username passed into the plugin can be affected by the bayes_sql_override_username config option.
If you load user scores from an LDAP directory, this will set the DSN used to connect. You have to write the DSN as an LDAP URL, the components being the host and port to connect to, the base DN for the search, the scope of the search (base, one or sub), the single attribute being the multivalued attribute used to hold the configuration data (space separated pairs of key and value, just as in a file) and finally the filter being the expression used to filter out the wanted username. Note that the filter expression is being used in a sprintf statement with the username as the only parameter, thus is can hold a single __USERNAME__ expression. This will be replaced with the username.
Example: "ldap://localhost:389/dc=koehntopp,dc=de?saconfig?uid=__USERNAME__"
The query must be one continuous line in order to parse correctly.
Here are several example queries, please note that these are broken up for easy reading, in your config it should be one continuous line.
Example: "cn=master,dc=koehntopp,dc=de"
Module naming is strict, name must only contain alphanumeric characters or underscores. File must have .pm extension.
"/path/module.pm" is the file to load, containing the module's perl code; if it's specified as a relative path, it's considered to be relative to the current configuration file. If it is omitted, the module will be loaded using perl's search path (the @INC array).
See "Mail::SpamAssassin::Plugin" for more details on writing plugins.
Plugins can override this internally if required.
MaxMind::DB::Reader (same as GeoIP2::Database::Reader) Geo::IP IP::Country::DB_File (not used unless geodb_options path set) IP::Country::Fast
city - use City database country - use Country database isp - try loading ISP database asn - try loading ASN database
Append full database path with colon, for example: isp:/opt/geoip/isp.mmdb
Plugins can internally request all types they require, geodb_options is only needed if the default location search (described below) does not work.
GeoIP/GeoIP2 searches these files/directories:
country: GeoIP2-Country.mmdb, GeoLite2-Country.mmdb GeoIP.dat (and v6 version) city: GeoIP2-City.mmdb, GeoLite2-City.mmdb GeoIPCity.dat, GeoLiteCity.dat (and v6 versions) isp: GeoIP2-ISP.mmdb GeoIPISP.dat, GeoLiteISP.dat (and v6 versions) directories: /usr/local/share/GeoIP /usr/share/GeoIP /var/lib/GeoIP /opt/share/GeoIP
The conditional accepts a limited subset of perl for security -- just enough to perform basic arithmetic comparisons. The following input is accepted:
( ) - + * / _ . , < = > ! ~ 0-9 whitespace
# Avoid lint error on older perl installs # Check SA version first to avoid warnings on checking perl_version on older SA if version > 3.004001 && perl_version >= 5.018000 body INVALID_RE_SYNTAX_IN_PERL_BEFORE_5_18 /(?[ \p{Thai} & \p{Digit} ])/ endif
Note that the above will still generate a warning on perl older than 5.10.0; to avoid that warning do this instead:
# Avoid lint error on older perl installs if can(Mail::SpamAssassin::Conf::perl_min_version_5010000) body INVALID_RE_SYNTAX_IN_PERL_5_8 /\w++/ endif
Warning: a can() test is only defined for perl 5.10.0!
Is similar to "has", except that it also calls the named function, testing its return value (unlike the perl function UNIVERSAL::can). This makes it possible for a 'feature' function to determine its result value at run time.
If the end of a configuration file is reached while still inside a "if" scope, a warning will be issued, but parsing will restart on the next file.
For example:
if (version > 3.000000) header MY_FOO ... endif loadplugin MyPlugin plugintest.pm if plugin (MyPlugin) header MY_PLUGIN_FOO eval:check_for_foo() score MY_PLUGIN_FOO 0.1 endif
Note: The version used is in the internal SpamAssassin version format which is "x.yyyzzz", where x is major version, y is minor version, and z is maintenance version. So 3.0.0 is 3.000000, and 3.4.80 is 3.004080.
This creates a function named "Mail::SpamAssassin::Conf::compat_xxxxxx", which returns true. It can be used for example in cf-files, similarly as existing "feature_" checks:
if can(Mail::SpamAssassin::Conf::compat_xxxxxx)
Name can only consist of [a-zA-Z0-9_] characters.
Mainly used by SpamAssassin distribution to handle backwards compatibility issues.
The following "tags" can be used as placeholders in certain options. They will be replaced by the corresponding value when they are used.
Some tags can take an argument (in parentheses). The argument is optional, and the default is shown below.
_YESNO_ "Yes" for spam, "No" for nonspam (=ham) _YESNO(spam_str,ham_str)_ returns the first argument ("Yes" if missing) for spam, and the second argument ("No" if missing) for ham _YESNOCAPS_ "YES" for spam, "NO" for nonspam (=ham) _YESNOCAPS(spam_str,ham_str)_ same as _YESNO(...)_, but uppercased _SCORE(PAD)_ message score, if PAD is included and is either spaces or zeroes, then pad scores with that many spaces or zeroes (default, none) ie: _SCORE(0)_ makes 2.4 become 02.4, _SCORE(00)_ is 002.4. 12.3 would be 12.3 and 012.3 respectively. _REQD_ message threshold _VERSION_ version (eg. 3.0.0 or 3.1.0-r26142-foo1) _SUBVERSION_ sub-version/code revision date (eg. 2004-01-10) _RULESVERSION_ comma-separated list of rules versions, retrieved from an '# UPDATE version' comment in rules files; if there is more than one set of rules (update channels) the order is unspecified (currently sorted by names of files); _HOSTNAME_ hostname of the machine the mail was processed on _REMOTEHOSTNAME_ hostname of the machine the mail was sent from, only available with spamd _REMOTEHOSTADDR_ ip address of the machine the mail was sent from, only available with spamd _BAYES_ bayes score _TOKENSUMMARY_ number of new, neutral, spammy, and hammy tokens found _BAYESTC_ number of new tokens found _BAYESTCLEARNED_ number of seen tokens found _BAYESTCSPAMMY_ number of spammy tokens found _BAYESTCHAMMY_ number of hammy tokens found _HAMMYTOKENS(N)_ the N most significant hammy tokens (default, 5) _SPAMMYTOKENS(N)_ the N most significant spammy tokens (default, 5) _DATE_ rfc-2822 date of scan _STARS(*)_ one "*" (use any character) for each full score point (note: limited to 50 'stars') _SENDERDOMAIN_ a domain name of the envelope sender address, lowercased _AUTHORDOMAIN_ a domain name of the author address (the From header field), lowercased; note that RFC 5322 allows a mail message to have multiple authors - currently only the domain name of the first email address is returned _RELAYSTRUSTED_ relays used and deemed to be trusted (see the 'X-Spam-Relays-Trusted' pseudo-header) _RELAYSUNTRUSTED_ relays used that can not be trusted (see the 'X-Spam-Relays-Untrusted' pseudo-header) _RELAYSINTERNAL_ relays used and deemed to be internal (see the 'X-Spam-Relays-Internal' pseudo-header) _RELAYSEXTERNAL_ relays used and deemed to be external (see the 'X-Spam-Relays-External' pseudo-header) _FIRSTTRUSTEDIP_ IP address of first trusted client (see RELAYSTRUSTED) _FIRSTTRUSTEDREVIP_ IP address of first trusted client (in reversed format suitable for RBL queries) _LASTEXTERNALIP_ IP address of client in the external-to-internal SMTP handover _LASTEXTERNALREVIP_ IP address of client in the external-to-internal SMTP handover (in reversed format suitable for RBL queries) _LASTEXTERNALRDNS_ reverse-DNS of client in the external-to-internal SMTP handover _LASTEXTERNALHELO_ HELO string used by client in the external-to-internal SMTP handover _AUTOLEARN_ autolearn status ("ham", "no", "spam", "disabled", "failed", "unavailable") _AUTOLEARNSCORE_ portion of message score used by autolearn _TESTS(,)_ tests hit separated by "," (or other separator) _TESTSSCORES(,)_ as above, except with scores appended (eg. AWL=-3.0,...) _SUBTESTS(,)_ subtests (start with "__") hit separated by "," (or other separator) _SUBTESTSCOLLAPSED(,)_ subtests (start with "__") hit separated by "," (or other separator) with duplicated rules collapsed _DCCB_ DCC's "Brand" _DCCR_ DCC's results _PYZOR_ Pyzor results _RBL_ full results for positive RBL queries in DNS URI format _LANGUAGES_ possible languages of mail _PREVIEW_ content preview _REPORT_ terse report of tests hit (for header reports) _SUBJPREFIX_ subject prefix based on rules, to be prepended to Subject header by SpamAssassin caller _SUMMARY_ summary of tests hit for standard report (for body reports) _CONTACTADDRESS_ contents of the 'report_contact' setting _HEADER(NAME)_ includes the value of a message header. value is the same as is found for header rules (see elsewhere in this doc) _TIMING_ timing breakdown report _ADDEDHEADERHAM_ resulting header fields as requested by add_header for spam _ADDEDHEADERSPAM_ resulting header fields as requested by add_header for ham _ADDEDHEADER_ same as ADDEDHEADERHAM for ham or ADDEDHEADERSPAM for spam
If a tag reference uses the name of a tag which is not in this list or defined by a loaded plugin, the reference will be left intact and not replaced by any value.
All template tag names must consist of only uppercase character set [A-Z0-9_] and not contain consecutive underscores (__).
Additional, plugin specific, template tags can be found in the documentation for the following plugins:
L<Mail::SpamAssassin::Plugin::ASN> L<Mail::SpamAssassin::Plugin::AWL> L<Mail::SpamAssassin::Plugin::TxRep>
The "HAMMYTOKENS" and "SPAMMYTOKENS" tags have an optional second argument which specifies a format. See the HAMMYTOKENS/SPAMMYTOKENS TAG FORMAT section, below, for details.
The "HAMMYTOKENS" and "SPAMMYTOKENS" tags have an optional second argument which specifies a format: "_SPAMMYTOKENS(N,FMT)_", "_HAMMYTOKENS(N,FMT)_" The following formats are available:
"add_header all Spammy _SPAMMYTOKENS(2,short)_"
Results in message header:
"X-Spam-Spammy: remove.php, UD:jpg"
Indicating that the top two spammy tokens found are "remove.php" and "UD:jpg". (The token itself follows the last colon, the text before the colon indicates something about the token. "UD" means the token looks like it might be part of a domain name.)
"add_header all Spammy _SPAMMYTOKENS(2,compact)_"
Results in message header:
"0.989-6--remove.php, 0.988-+--UD:jpg"
Indicating that the probabilities of the top two tokens are 0.989 and 0.988, respectively. The first token has a declassification distance of 6, meaning that if the token had appeared in at least 6 more ham messages it would not be considered spammy. The "+" for the second token indicates a declassification distance greater than 9.
For example, preference file entry:
"add_header all Spammy _SPAMMYTOKENS(2,long)_"
Results in message header:
"X-Spam-Spammy: 0.989-6--0h-4s--4d--remove.php, 0.988-33--2h-25s--1d--UD:jpg"
In addition to the information provided by the compact option, the long option shows that the first token appeared in zero ham messages and four spam messages, and that it was last seen four days ago. The second token appeared in two ham messages, 25 spam messages and was last seen one day ago. (Unlike the "compact" option, the long option shows declassification distances that are greater than 9.)
A line starting with the text "lang xx" will only be interpreted if SpamAssassin is running in that locale, allowing test descriptions and templates to be set for that language.
Current locale is determined from LANGUAGE, LC_ALL, LC_MESSAGES or LANG environment variables, first found is used.
The locales string should specify either both the language and country, e.g. "lang pt_BR", or just the language, e.g. "lang de".
Example:
lang de describe EXAMPLE_RULE Beispielregel
Mail::SpamAssassin(3) spamassassin(1) spamd(1)
2024-04-12 | perl v5.38.2 |