procmail
[Top] [All Lists]

Re: Restricting mail size to under 10K

1998-02-25 21:16:42
Daryl Ching <dching(_at_)alii(_dot_)nosc(_dot_)mil> writes:
I wish to restrict the size of all e-mail sent to a particular domain to 
under 10K.  When a message larger than 10K is received, I want to reject 
the message back to the sender with an attachment message explaining why 
the e-mail was rejected.  Anyone know how to extract the sender's address 
and relay the back the original message.

If the domain involved is the only one being served by this machine,
then I would strongly suggest doing this inside your MTA (e.g., sendmail)
instead of with procmail.  Your MTA can reject the message without
having to store it all on your machine first.  Think efficiency.

If this doesn't work for you, consider changing things so that it does.

If you really can't make it work, then something like the following
in the proper procmailrc might work:

        :0
        * > 10240
        {
            # Bounce messages should generally be sent to the envelope
            # sender, not the header sender.
            :0
            * ! ^\/Return-Path:\/.+
            * ! ^\/From  *\/[^ ]+
            { ENV_SENDER = $MATCH }
            :0 E
            {   # This message doesn't have an envelope line!
                # This really shouldn't happen, so consult your
                # psychiatrist, or sendmail.cf hacker.  We'll
                # just drop the message on the floor, as there
                # really isn't a better place to put it.
                HOST
            }
            :0
            | (echo "To: $ENV_SENDER"; \
               echo "Subject: Message Too Large: Rejected" ; \
               echo ""; cat - ) | $SENDMAIL $SENDMAILFLAGS -- "$ENV_SENDER"
        }


Philip Guenther

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