limit archive size?
Mark Martinec
Mark.Martinec+amavis at ijs.si
Mon Mar 21 18:46:41 CET 2011
Michael,
> > if ($msginfo->msg_size < 1024*1024) {
> > Amavis::do_quarantine($conn,$msginfo, undef,
> > ['archive-quarantine'], 'sql:');
> > }
>
> back on this. I do want to quarantine the whole email if it is
> 'spam/virus/attachment'. its only in certain circumstances that I want
> to limit this to 1M. and, only on some systems.
>
> so, start with:
> my($content) = $msginfo->is_in_contents_category(CC_CLEAN);
> if ($content && $msginfo->msg_size < 1024*1024 ) {
Close, but a CC_CLEAN may be set (and usually is) even for mail
with other ccats turned on. You should be checking explicitly for
undesired contents categories. For example:
my $unwanted = $msginfo->setting_by_contents_category(
{CC_SPAMMY,1, CC_SPAM,1, CC_BANNED,1, CC_VIRUS,1} );
if ($unwanted && $msginfo->msg_size < 1024*1024 ) { ...
Btw, the CC_* constants need to be imported from Amavis::Conf,
or their full name given, when using them in Amavis::Custom.
See below.
> also, looks like (in 2.6.4) do_quarantine might have more fields I need
> to populate.
>
> my($conn,$msginfo,$hdr_edits_inherited,$recips_ref,
> $quarantine_method, at snmp_id) = @_;
The @snmp_id may be left empty or unspecified.
The call in the example should be alright.
package Amavis::Custom;
BEGIN {
import Amavis::Conf qw(:platform :confvars c cr ca);
import Amavis::Util qw(do_log untaint min max);
}
sub new {
my($class,$conn,$msginfo) = @_;
bless {}, $class;
}
sub before_send {
my($self,$conn,$msginfo) = @_;
my $unwanted = $msginfo->setting_by_contents_category(
{CC_SPAMMY,1, CC_SPAM,1, CC_BANNED,1, CC_VIRUS,1} );
if ($unwanted && $msginfo->msg_size < 1024*1024) {
Amavis::do_quarantine($conn,$msginfo, undef,
['archive-quarantine'], 'sql:');
}
}
Don't know what you mean by 'if it is an attachment'.
To detect attachments you'd need to traverse the MIME tree,
rooted at $msginfo->parts_root, or if you prefer the
MIME-Tools object: $msginfo->mime_entity.
Mark
More information about the amavis-users
mailing list