Rajiv,
At 11:09 AM 14/4/2002, rajiv saha wrote:
hello sir,
I am in need of a procmail script which will "force
maximum mailbox size limit(such as, mail box size
should not increase 4MB)".
Rajiv,
After reading the excellent tips in the procmail mailing list, I came up with
the following recipe. I actually do not use this yet, so it has not been fully
tested, but here you go.
I call it by assigning QUOTA then including the recipe, e.g.
QUOTA=4000000 # bytes
INCLUDERC=/your/path/to/quota.rc
# quota.rc by Stuart Clark
#
# If mailbox size exceeds QUOTA, send reply email
# using /etc/procmail/messages/bounce-exceed-quota.txt
#
LOGFILE="/tmp/procmail.quota.log"
VERBOSE=YES
PATH="/usr/bin:$PATH:/usr/local/bin"
SHELL=/bin/sh
:0 # if QUOTA is set to something, then..
* QUOTA ?? .
{
# How can I do a conditional test, not on the header or body, but on the
# variable ${MAILBOX_SIZE_}, then reject the message if
${MAILBOX_SIZE_} is
# greater than QUOTA bytes? Answer..
MAILBOX_SIZE_REPORT_=`wc -c ${DEFAULT}`
:0 # if
* MAILBOX_SIZE_REPORT_ ?? ^^ *\/[0-9]+
{ MAILBOX_SIZE_=${MATCH} }
# Note: the next recipe tests the size of the box without the current
message; if
# the box has exactly QUOTA bytes and you get any size message in, it
will be
# accepted. If you want to test based on the size that the box would
be if
# the message were added to it, add the size of the current message
before
# comparing to QUOTA
:0 # positive difference means box is already bigger than
$MAILBOX_SIZE_ bytes
* $ ${MAILBOX_SIZE_}^0
* $ -${QUOTA}^0
{
# keep a backup for a while
:0c
/tmp/quota.${LOGNAME}
:0 # lose items we don't want to bounce
* 9876543210^0 ^FROM_DAEMON
* 1^0 ^X-Loop: X-BOUNCE-FILE-SIZE
/dev/null
:0fi # double the head, lose the body
* ^Subject: \/.*
| sed -eH -e /./b -eg -eq
SUBJECT="${MATCH}"
:0f # invert and let second copy of head (the new body) be
cited:
| formail -rtk \
-I"Subject: Returned Mail: ${SUBJECT}" \
-I"From: MAILER-DAEMON(_at_)tpg(_dot_)com(_dot_)au" \
-A"X-Bounced-Reason: Mailbox quota exceeded ${QUOTA}
bytes" \
-A"X-Loop: X-BOUNCE-FILE-SIZE"
# insert explanation between head and new body;
:0wf # explanation file should end with an empty line
| sed -e '1,/^$/!b' -e/./b -e 'r
/etc/procmail/messages/bounce-exceed-quota.txt'
:0 # send this bounced message from
MAILER-DAEMON(_at_)your(_dot_)domain using sendmail
! -fMAILER-DAEMON(_at_)your(_dot_)domain -t
}
}
#end
Kind regards, Stuart
Stuart Clark sclark(_at_)tpg(_dot_)com(_dot_)au
_______________________________________________________________
System Administration Supervisor
(02) 9850 0907
TPG Internet
www.tpg.com.au
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail