procmail
[Top] [All Lists]

RE: procmail Efficiency Question

1999-03-24 09:14:22
On Wed, 24 Mar 1999 10:19:20 -0500, "Banerjee, Tapas"
<Tapas(_dot_)Banerjee(_at_)gs(_dot_)com> wrote:
[Banerjee, Tapas]  ..........  
Q 1: Will it be a better idea to trap the Arguments as SUBJECT =
`formail -zx Subject` dynamically and pass that in heading field
i.e. in place of -i"Subject: DAVINCI REPORTS " use -i"Subject:
$SUBJECT_reports " ?
I'm not sure I understand really, but this does not sound like it
would buy you anything. If you want to grab the Subject verbatim, it's
cheaper to do a simple grab:
     What I tried to say is, I am putting the same recepie in same rc
file, for n(12) times for different subjects.
     Currently, I write the filtered mail on a file has the format
<$SUBJECT>_mails.<date>.
     Rather than twelve receipie with  hard quoted subject fields, I
thought I can replace them by ONLY ONE
<...>
-i"Subject: monalisa REPORTS " ) >>
monalisa_mails.`date '+%H%M%S'`
     ...... n list .....
     can be replaced by a single list
     as 
     SUB=`formail -zx Subject` 
   * !$SUB ?? $VALID_SUBJECTS # one of the valid subject
        | (formail -A"Bcc: internal_list" \
-I"To: ess_mailing_list" \
-I"From: ess(_at_)nyamdweb246(_dot_)gsam(_dot_)gs(_dot_)com" \
-i"Subject: $SUB REPORTS " ) >> $SUB_mails.`date
'+%H%M%S'`
     Will it offer more efficiency?

Only in terms of maintainer efficiency (provided you get rid of the
needless external call, which makes it less efficient in terms of
resource usage), but that's a worthy cause.

    :0
    * ^From [^ ]+  \/.*
    { ... construct DATE from $MATCH ... }

    :0:
    * $ ^Subject:[      ]*\\/$VALID_SUBJECTS
    *    ... whatever other conditions you had here ...
    | formail -A "Bcc. internal_list" \
            -I "To: ess_mailing_list" \
            -I "From: ess(_at_)nyamdweb246(_dot_)gsam(_dot_)gs(_dot_)com" \
            -i "Subject: $MATCH REPORTS" >> $MATCH_mails.$DATE

Like I said, there are old threads about getting the time stamp out of
the From_ line (the DATE stuff in the first, sketchy recipe). 

I think you need to escape the backslash in the Subject grab if you
have an $ modifier on the condition but I'm too lazy to test that.

Note that the correct syntax for what you tried would be

    * ! SUB ?? $VALID_SUBJECTS
      ^
although I can't say I understand why this would be negated.

I assume VALID_SUBJECTS would be a properly parenthesized regex such
as (galileo|monalisa|whatever) -- if the parentheses are missing, you
will need to add them to the recipe I wrote.

Q2. I also wanted to move first line of body to subject field in
Japanese(Kanchi) text.
<...>
Or do you mean you would like Procmail to produce the correct
=?iso-2022-jp?B?blahblahblah?= stuff in the Subject from something
encoded in some different way which you grabbed out of the body of the
message?
send the required  "Japnease subject" 
     to be forwarded, on 1st line of  mail body. Subject will be in
english( e.g davinci, galeleo..). I will use procmail, filter
     first line of body and put that line on Subject of outgoing mail.  I
could able to do so in English,
     but if we use Japnease chartecter on body, the Subject field did not
look like Japnease charecter on viewing
     the actual outgoing mail on Japnease MS-Outlook. 

Okay, so you mean a message like this:

    From: Japanese person perhaps
    To: you
    Subject: galileo
    Mime-Version: 1.0
    Content-Type: text/plain; charset=iso-2022-jp
    Content-Transfer-Encoding: 8bit

    !%(_at_)f  <<-- mock Japanese Subject

    Rest of message, probably also in Japanese

should be transformed into

    From: Japanese person perhaps
    To: you
    Subject: =?iso-2022-jp?B?ISVAZgo=?=
    Mime-Version: 1.0
    Content-Type: text/plain; charset=iso-2022-jp
    Content-Transfer-Encoding: 8bit

    Rest of message, probably also in Japanese

... where ISVAZgo= is the correct encoding of the !%(_at_)f word?

If yes, what exactly should trigger this action (the existence of
iso-2022-jp in the Content-Type line, perhaps)?

    :0
    * some additional condition, perhaps?
    * B ?? ^^\/[^a-z]+
    {
        JPSUBJECT=`echo "$MATCH" | mmencode` }

        :0fwh
        | formail -I "Subject: =?iso-2022-jp?B?$JPSUBJECT?="

        :0bwh
        ... trimming of first line of body left as an exercise ...
    }

Again, I'm not sure if RFC2047 requires you to always have
Mime-Version: 1.0 in the headers before you're allowed to use this
crazy encoding, but then if the body already contains Japanese, I'll
guess it would be safe to assume the message is already a MIME
message.

You might want to read the relevant RFCs in order to gain a better
understanding. There are links to them on the Procmail Links page,
<http://www.iki.fi/era/procmail/links.html>

/* era */

-- 
.obBotBait: It shouldn't even matter whether     <http://www.iki.fi/era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>
 * Sign the European spam petition! <http://www.politik-digital.de/spam/en/> *

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