procmail
[Top] [All Lists]

Re: formail options ? exitcode ? filter flags?

1997-06-29 04:07:00
wwgrol(_at_)sparc01(_dot_)fw(_dot_)hac(_dot_)com (W. Wesley Groleau x4923) 
writes:
Two recipes at the beginning of my ...rc and questions in [brackets]

# Prevent loops
:0 w
* ^X-Loop: noloop(_at_)fw(_dot_)hac(_dot_)com
{
 EXITCODE=77  
        [I have seen 77 and 67, but can't find clear documentation
         on what they mean (what their effect is) nor on other options]

 :0
 loops  [ this part just temporary, to see if any loops (almost) occur ]
}

The numeric constants for EXITCODE come from the sysexits.h header
file.  Look at the file /usr/include/sysexits.h or
/usr/ucbinclude/systexits.h.  77 is EX_NOPERM while 67 is EX_NOUSER.
Either one will cause a bounce message to be generated by sendmail.

However, I think it's a _very_ bad idea to respond to a possible loop
by generating another message, even 'just' a bounce message.  I would
suggest just delivering it to "loops" and returning success to sendmail:

        :0
        * ^X-Loop: noloop(_at_)fw(_dot_)hac(_dot_)com
        loops

I'd also suggest using something more unique that 
"noloop(_at_)fw(_dot_)hac(_dot_)com".
What if someone else at fw.hac.com does the same thing?  Mail from them
would go into your loops folder!  That's why it's recommended to use
something unique to *you*, say, wwgrol(_at_)fw(_dot_)hac(_dot_)com(_dot_)


# Regenerate "From" lines to make sure they are valid
:0 fhw
| formail -I "From " -a "From "

       [ I have been getting some messages split at a From line.
         Procmail handles the message properly as a single message, but
         the mail-reading tools split the message.  The formail man page
         says that "bogus" from lines will be escaped with >  but this
         never happens.

Actually, it says:

     If formail is started without any command line  options,  it
     will  force  any  mail coming from stdin into mailbox format
     and will escape all bogus `From ' lines with a `>'.
 

Those look like command line options to me.  Besides, you would need to
filter the entire message through formail, not just the header.


         What is a bogus from line?  Could this be failing because the
         bogus from line is part of a quoted header with more than two
         header lines (see man formail under -m)?  If that's it, then is
         there no way to fix it?  It is entirely conceivable that the
         real header will have eight fields and the quoted header will
         have ten.  (I have seen some with that many Received: fields.)

That's only when formail is splitting a mailbox or digest with the -s flag.



          What (in more detail than the man page) does 
          '-I "From " -a "From "' do?

          Would the following be better?  Or a combination of both?  Or
          do I need something more?]


You probably just need to be invoking procmail with the -Y flag.  That
tells procmail to handle the escaping of "From " lines in the body.


# Standardize the formats of messages (untried idea for filter)
:0 fhW
| formail -c -z -k 

        [I do not expect to receive any digests, but if I do, I want
         them left in digest form until some later recipe.]

Ick!  Do you have a really broken mail reader that doesn't handle
continued header line?  If so, I would suggest you can't trust a mail
program that is *that* broken with *anything*, much less your mail.
The -k flag is unneccesary because you're not feeding the body into
formail.  That leaves the -z flag effect of trimming leading and
trailing whitespace.  I'd suggest doing that only if you have later
recipies that expect such a format, otherwise, why bother?


Philip Guenther

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