procmail
[Top] [All Lists]

Re: Mailbox limit

2001-08-03 07:23:06
On  3 Aug, George Chelidze wrote:
| Hello,
| I have posted several messages about mailbox limit. I was pointed to use
| procmail for this. I am new to procmail but managed to write the
| following recipe for it.
| 
| MAXSIZE=10240 #maximum mailbox size in bytes = 10Mb
| BOXSIZE=`ls -l /var/spool/mail/${LOGNAME} 2>/dev/null | while read a b c
| d e f; do echo $e; done`
| FULL=`expr ${BOXSIZE} \> ${MAXSIZE}`
| 
| :0
| * $FULL ?? 1
| {
|     :0
|     * ! ^Subject.*Mail Delivery Failure
|     | (formail -r -I"From: postmaster(_at_)geo(_dot_)net(_dot_)ge" \
|                          -I"Subject: Mail Delivery Failure" \
|                          echo "Sorry message undelivered. reason:
| mailbox full") | $SENDMAIL -t
|     :0 E
|     /dev/null
| }
| 
| I have tested it and its seem to work fine. But I am not sure there are
| no errors in it. It would be great if someone check this code. Any
| comments and considerations will be appreciated. Thank you in advance
| 

George,

A couple things. 10240 is not 10Mb. You probably mean something more
like 10485760.[1]  Also BOXSIZE=`ls -l $DEFAULT |awk '{print $5}'` 
might be a reasonable simplification.  You can also use scoring to do
the arithmetic instead of another variable and expr. Finally, your
recipe would allow a 10Mb message to be delivered to a 9.9Mb spool
file, which probably wouldn't be desirable. Something like this
(untested) might work:

MAXSIZE=10485760
BOXSIZE=`ls -l $DEFAULT |awk '{print $5}'`

:0
* $ $MAXSIZE^0
* $ -$BOXSIZE^0
{
  # mbox is not over limit before delivery 
  :0
  * $ > $=
  { your action for failure, because mbox would be full after delivery }
  :0    
  $DEFAULT
}
:0 E
{ your action for failure, because mbox was full before delivery }

[1] Unless your ls is set up locally to report blocks not file size. If
so, you might be "cheating" users of some of the 10MB.

-- 
                   /"\
Don Hammond        \ /     ASCII Ribbon Campaign
Raleigh, NC US      X        Against HTML Mail,
                   / \      and News Too

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>