amavisd-new is a fairly widespread product for feeding from the hands of spamassassin-a and clamav-a. In spite of this, some of the options for the settings are clearly not enough. At least, the author was already thinking about writing his own patch, until he accidentally came across the Amavis :: Custom hook in the code.
It all started with the fact that it took to skip all checks in amavisd. This is easy to do with a known sender, either the recipient or divided by port-based banks. The task becomes less trivial if the signal is a header that has already been received for checking the electronic message. This is where Amavis :: Custom comes in (and in most other cases).
Judging by the documentation from the sample file, custom clothespins (?) Are available from the version of amavisd-new-2.5.0 and allow to be implemented in the following steps:
Message processing sequence
# received a letter, disassembled, collected basic information
# * custom hook: new () - you can view the initial data, load banks, set some parameters
# letter verification, assignment of marks
custom hook: checks () - called after checks for spam and viruses, but before deciding on the further fate of the letter. Here you can play with the estimates.
# deciding on the fate of the letter (searches in * _lovers, threshold values, ...)
# quarantine
# sending notifications (admins, recipients)
# * custom hook: before_send () - you can send your own notifications, organize quarantine, change the message, modify mail
# forwarding (if not blocked)
# * custom hook: after_send () - you can suppress DSN, send reports
# send DSN (when necessary)
# logging, statistics
* custom hook: mail_done () - may inspect results (did not catch the point)
The complete example provides a significant piece of code for the expansion of consciousness. The author, however, required quite a little. As a result of a brief reflection, amavisd-custom.conf contains the following letters:
')
# try to skip checks if spam
package Amavis :: Custom ;
use strict ;
sub new {
my ( $ class , $ conn , $ msginfo ) = @_ ;
my ( $ self ) = bless { } , $ class ;
for my $ curr_head ( @ { $ msginfo -> orig_header } ) {
if ( $ curr_head = ~ / ^ X-SpamTest-Status: spam / i ) {
for my $ r ( @ { $ $ msginfo -> per_recip_data } ) {
$ r -> bypass_spam_checks ( 1 ) ;
$ r -> bypass_banned_checks ( 1 ) ;
}
}
}
$ self ;
}