[Mimedefang] over quota message

Matej Vela mvela at irb.hr
Mon Jan 26 12:09:19 EST 2004


On Mon, Jan 26, 2004 at 02:04:28PM +0100, AKSurF wrote:
> Is there any way to make mimedefang (2.39) bounce or tempfail
> maildelivery when the recipient is over quota?

Sort of.  The following (untested!) code won't work for aliases
(sendmail expands them only after calling milter), but it should work
for virtusertable entries and LDAP routing:

use Quota;

sub filter_recipient {
    my ($recipient, $sender, $ip, $hostname, $first, $helo,
	$rcpt_mailer, $rcpt_host, $rcpt_addr) = @_;

    if ($rcpt_mailer eq 'local' && (my $uid = (getpwnam($rcpt_addr))[2])) {
	# Change this to your mail spool directory.
	my $dev = Quota::getqcarg('/var/mail');

	if (my ($bc, $bs, $bh, $bt, $ic, $is, $ih, $it)
	    = Quota::query($dev, $uid, 0)) {
	    my $time = time;
	    if (($bs && $bc >= $bs && $time >= $bt)
		|| ($is && $ic >= $is && $time >= $it)
		|| ($bh && $bc >= $bh)
		|| ($ih && $ic >= $ih)) {
		return ('TEMPFAIL', 'Mailbox full', '450', '4.2.2');
	    }
	}
    }

    return ('CONTINUE', 'ok');
}

Don't forget to start mimedefang with option -t.



More information about the MIMEDefang mailing list