[Mimedefang] MaxMIMEParts
David F. Skoll
dfs at roaringpenguin.com
Fri Feb 5 11:41:26 EST 2010
Jason Bertoch wrote:
> My Perl skills are weak at best...would someone be willing to help me with the
> syntax to add a debug line to my filter that logs the number of MIME parts in
> each message processed?
There's no easy way to pull that out of the MIME::Parser. The variable
$parser is a "my" variable in the private do_scan function. This
function (untested!) called on the $entity from filter_end might do
the trick:
sub count_parts
{
my ($entity) = @_;
return 1 unless $entity->is_multipart;
my $count = 1; # The multipart container is itself a part
foreach my $part ($entity->parts) {
$count += count_parts($part);
}
return $count;
}
It's a recursive function that may be somewhat slow on large or deeply-nested
MIME messages.
Regards,
David.
More information about the MIMEDefang
mailing list