procmail
[Top] [All Lists]

Re: mime header relating to fax images

2001-02-25 17:22:06
Harry Putnam wrote:
        :0f
        *^Subject:.*page eFax
        *^Content-Type: application/octet-stream; name=\"[^.]*\.tif\"
  ##  (line wrapped for mail  - Note extra backslash)
|sed 's/\(^Content-Type: \)\(application\/octet-stream\)\
\(; name=\"[^.]*\.tif\"\)/\1image\/tif\3/'

But the Regexp at *^Content...  misses this line:

      Content-Type: application/octet-stream; name="aeanvga9.tif"
...
I seem to remeber that without :0hb  the default is to include header
and body.  But just in case I also tryid `:0hbf'

"h" and "b" specify what part of the message gets sent to the filter,
so that last attempt just makes procmail pipe both through sed, and
yes, you remember correctly, that's the default anyway. What you have
in mind, though, is to tell procmail that you want the conditions to
refer to both header and body; that's what "H" and "B" are for. Only
"H" is the default, thus the "Content-Type:" line (appearing in the
body) isn't matched. If you want both conditions to check header and
body, use ":0 HB f".

Better yet, since you need to check only the header for the "Subject:"
line and only the body for the "Content-Type:" line, you can use the
"H" and "B" pseudo-variables, and since you only want to change the
body in the pipe, the recipe can be made a bit faster by adding "b" -
so, putting everything together, I'd suggest this:

       :0 fb  # or fbw (a bit safer)
       * H ?? ^Subject:.*page eFax
       * B ?? ^Content-Type: application/octet-stream; name="[^.]*\.tif"
       | sed ...

BTW, you don't need to escape the double quotation marks (neither in
the procmail condition nor in the sed command), and you could make the
sed line a bit more readable (IMHO) by using a different delimiter for
"s" so that you could use plain "/" instead of "\/", e.g.,
"s~...~...~" or "s_..._..._".
       
/HW
_______________________________________________
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>