procmail
[Top] [All Lists]

re: Mailbox limit

2001-08-04 11:20:52
On  4 Aug, George Chelidze wrote:
| Dear Don:
| 
| 1. 1024 is only used for example purposes, so If its ok with the rest of
| code I'll set it to 10485760 (10Mb)

Ok, that makes sense.

| 2. I do check if current size + message size is more then maxsize
| (LINE 6), Don't I?

Yes, you do, and I'm embarassed again. I don't know how, but I missed
that. 

Trying to be more careful now... there's a couple things (quoting from
previous message).

| MAXSIZE=1024
| BOXSIZE=`[ -f $DEFAULT ] && ls -l $DEFAULT | while read a b c d e f; do
| echo $e; done || echo 0`
| 
| :0
| * $ $MAXSIZE^0
| * $ -$BOXSIZE^0
| {
|     :0
|     * > $=
|     {
|          :0
|          * ! ^Subject.*mail delivery
|          | (formail -r -I"From: postmaster(_at_)geo(_dot_)net(_dot_)ge" \
|                               -I"Subject: mail delivery" \
|                               -I"Return-Path: 
postmaster(_at_)geo(_dot_)net(_dot_)ge"; \
|                               echo "Mailbox full") | $SENDMAIL -t
|          :0 E
|          /dev/null
|     }
| }
| 

If a message *fails* the first (outer) recipe, then the mbox is already
full. But you don't do anything with that message, which means it'll
probably get delivered to $DEFAULT. It might have been clearer if the
logic of the first recipe was reversed, but let's stick with what you've
got, which goes like this:

1. Test BOXSIZE < MAXSIZE.
2. If #1 true, test BOXSIZE + incoming message < MAXSIZE
3. If #2 false, send postmaster message and ditch message,
                *else* ditch incoming msg.

What's missing is sending postmaster msg and ditching incoming message
if #1 false, i.e. BOXSIZE already > MAXSIZE.

To fix that, immediately following what you already have add:

:0 Eh
* ! ^Subject.*mail delivery
| (formail -r -I"From: postmaster(_at_)geo(_dot_)net(_dot_)ge" \
                     -I"Subject: mail delivery" \
                     -I"Return-Path: postmaster(_at_)geo(_dot_)net(_dot_)ge"; \
                     echo "Mailbox full") | $SENDMAIL -t
:0 E
/dev/null    # see note 1

Notice, I added an "h" flag to the recipe to send only the headers to
the pipe delivery. You don't need the body of the incoming message. You
should add the h flag to the other reject recipe as well.

Notes:
1). I want to point out you're "else" recipe after #3 (and which I've
included just above), and make sure it's what you intended. The pipe to
formail and sendmail will constitute a successful delivery for
procmail's purposes, presuming the action doesn't fail, so further
processing will stop right there. If that additional recipe is there to
ditch the incoming message, it's unnecessary. If it's there to ditch the
message in case the pipe above it fails, I believe the "E" flag should
be an "e" flag instead. If it's there in case the condition doesn't
match, i.e. The Subject: does contain "mail delivery", then that's ok
(but see note 3 below).

2) I'm not sure if you need or want to set Return-Path:. formail -r will
discard the one on the incomong message, and I believe it will be set
by the MTA on the receiving end.

3) I'm guessing that the test for ! ^Subject.*mail delivery is to avoid
a mail loop, which is also the reason for the "E" recipe that follows.
That's a good idea, but the canonical way for preventing mail loops is
with an X-Loop: header (man 5 procmailex). Off the top of my head I
can't think of any scenarios where your method will bite you, but maybe
someone else will. Anything that gets inside the second recipe is
plonked anyway, and anything that doesn't get to that recipe isn't
getting a reply, so it appears to be ok.

-- 
                   /"\
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>