procmail
[Top] [All Lists]

Re: Procmail can delivery, but that is it

1998-11-09 00:29:24
"Clement" <support(_at_)ans(_dot_)com(_dot_)au> writes:
I installed Procmail for the first time.  I want use it as a filter to
separate large emails from the others and send notice to the receipient that
a large email is arrived.  However, I can only get procmail to delivery the
emails but the not the notice message.  Can you give me a hand?

Have you turned on verbose logging to see what is happening?  It's
always a good first step to stick something like:

        LOGFILE=/var/log/procmail.log
        VERBOSE=on

at the top of the problem procmailrc and see what procmail is actually
doing.  I choose "/var/log/procmail.log" for the above because you
would stick this at the top of the /etc/procmailrc file, but if you
were doing this on your personal .procailrc would would want to use
something like "$HOME/procmail.log".


...
Procmail setting:              content of file /etc/procmailrc is

  LARGEFOLDER=/var/spool/mail-large
  LENOTICE=/etc/mail/large_email_notice

  :0:
  * < 2000
  $ORGMAIL

Wow, only 2K?!?  I quick checks shows that over the last 60,025
messages I received, the *average* message size was 5372 bytes with 60%
being 2000 bytes or longer.  Also, I would suggest using $DEFAULT instead
of $ORGMAIL.  They should be same at this point, but it's a good habit
to get into.


  :0 c:
  $LARGEFOLDER/$LOGNAME

  :0
  | $SENDMAIL $LOGNAME < $LENOTICE

This recipe needs the 'i' flag to prevent procmail from thinking that
because the pipe was never read from the action must have failed.  It
would also be much more efficient to simply deliver the large email
notice from inside procmail -- why call sendmail when it'll just call
procmail again.  You also risk a loop if you ever accidentally make the
notice bigger than the limit.  Change that last recipe to:

        :0 ai:
        |cat $LENOTICE >>$DEFAULT

BTW: You do know that this /etc/procmailrc file effectively disables
every user's .procmailrc file for normal mail delivery, don't you?  If
that was your intent, that's fine, though your users may complain about
that policy.  If it wasn't, then you should rearrange /etc/procmailrc
to look like this:

        :0 c:
        * ! < 2000
        $LARGEFOLDER/$LOGNAME

        # If the previous recipe was successfully performed then sub
        # the notice for the current message.  Users can then process
        # the notice with their .procmailrc
        :0 afi
        |cat $LENOTICE

That's it!  The delivery of the notice and short messages is handled by
the user's .procmailrc or the implicit delivery on exit from it.


BTW: can I ask why you're doing this?  You still have to store the
message somewhere, it still has to be loaded into memory by procmail,
and you've made it impossible for a user to filter out large messages
on their own.  What am I missing?


Philip Guenther

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