[Mimedefang] RE:Email attachment size

Jan Pieter Cornet johnpc at xs4all.nl
Fri Sep 9 19:14:05 EDT 2005


On Fri, Sep 09, 2005 at 04:40:11PM -0500, Pramod Anugu wrote:
> The below does limit for every users. But I need to limit for certain users
> 5 MB, For some users 20 MB and for some 50MB.
> thanks

Most ESMTP mailers nowadays will tell you the size of the email using
an option on the MAIL FROM line, so when you receive the recipients,
that is usually available. You'd have to explicitly pass the {msg_size}
macro from sendmail, though. That macro isn't available by default,
so it needs to be added to `confMILTER_MACROS_ENVFROM', and you need
to tell mimedefang by passing "-a msg_size". Then in filter_recipient
you'd do something like this:

sub filter_recipient {
    my($recipient) = @_;

    my $maxsize = find_maxsize_for_recipient($recipient);
    read_commands_file();
    if ( $SendmailMacros{msg_size} > $maxsize ) {
	return('REJECT', "mail too big", 522, '5.2.2'); # 522 = quota exceeded
    }
    ...

However, not all mailers pass this value, so this isn't completely
failsafe, but it might be enough for your purpose. Rejecting the email
after DATA is messy, especially when you have multiple recipients
with conflicting quota limits.

-- 
#!perl -wpl # mmfppfmpmmpp mmpffm <pmmppfmfpppppfmmmf at fpffmm4mmmpmfpmf.ppppmf>
$p=3-2*/[^\W\dmpf_]/i;s.[a-z]{$p}.vec($f=join('',$p-1?chr(sub{$_[0]*9+$_[1]*3+
$_[2]}->(map{/p|f/i+/f/i}split//,$&)+97):qw(m p f)[map{((ord$&)%32-1)/$_%3}(9,
3,1)]),5,1)='`'lt$&;$f.eig;                                # Jan-Pieter Cornet



More information about the MIMEDefang mailing list