procmail
[Top] [All Lists]

Re: Autoresponder

1998-09-23 13:07:12
grommit(_at_)grove(_dot_)ufl(_dot_)edu asked,

| I'm trying to setup an autoresponder to no only delete messages that are
| over 50k total size, but to send a message to the sender that tells them
| that the message is too large.

| This is the recipe that I am trying (basically cut and paste from the
| archives)

|         :0
|         * > 51200
|         {
|             # 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"
|         }

Mike, you have your inverse DeMorgan inside out.  The first braces are
entered if the two conditions on it are both met: no Return-Path: and no
From_.  The `E'lse brackets are entered otherwise: if there is a Return-Path:
or a From_.  So let's straighten it out:

         :0
         * > 51200
         {
             # Bounce messages should generally be sent to the envelope
             # sender, not the header sender.
             :0
             * ! ^\/Return-Path:\/.+
             * ! ^\/From  *\/[^ ]+
             {   # 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 E
             {
              ENV_SENDER = $MATCH

              :0
              | (echo "To: $ENV_SENDER"; \
                 echo "Subject: Message Too Large: Rejected" ; echo ""; \
                 cat - ) | $SENDMAIL $SENDMAILFLAGS -- "$ENV_SENDER"
             }
         }

or since we are going to use the extracted value right away, we don't need
to save it in another variable, and we can save one layer of braces:

         :0
         * > 51200
         {
             # Bounce messages should generally be sent to the envelope
             # sender, not the header sender.
             :0
             * ! ^\/Return-Path:\/.+
             * ! ^\/From  *\/[^ ]+
             {   # 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 E
             | (echo "To: $MATCH"; \
                 echo "Subject: Message Too Large: Rejected" ; echo ""; \
                 cat - ) | $SENDMAIL $SENDMAILFLAGS -- "$MATCH"
         }

You might want to add * ! ^FROM_DAEMON to the outer conditions so as not
to bounce such mail back and to put in some loop detection.

<Prev in Thread] Current Thread [Next in Thread>
  • Autoresponder, Zoomdoggie
    • Re: Autoresponder, David W. Tamkin <=