procmail
[Top] [All Lists]

Re: Put From/Subject into BODY

1997-03-20 15:36:26
Mitusuru (or Mitsuru?  The header and the signature disagreed) Furukawa asked,

| I want to create email-to-pager script for Japanese pager service.
| What seems to be different from services in other countries is that
| only the body of email is displayed on pager.
| So I want to reorganize the incoming email
| by extracting From: and Subject and put them in Body,
| and replace From: to my address, To: to my pager service address.
| Subject is ignored by the pager service.
| 
| I created following script but it is painfully far from functional.
| Please give me advice.
| 
| :0 c
| * (^To:.*(important|urgent)|^From:.*(important.com|urgent.com))
| {
| FROM=`formail -xFrom:`
| SUBJECT=`formail -xSubject:`
| (formail -I"From: furu(_at_)009(_dot_)com" \
| -I"Subject: forwarding to pager" \
| -I"To: 0399999999(_at_)docomonet(_dot_)or(_dot_)jp" \
| $FROM $SUBJECT)|$SENDMAIL -t
| }

OK ... I already do something similar in some of my own recipes.  First
suggestion: use only one formail invocation to get both From: and Subject:;
second, use -X rather than -x so that the resulting text labels them for the
recipient.  Third, we're probably better off using ^TO_ (or ^TO if your
version of procmail doesn't support ^TO_) than "^To:.*".

  # Use ^TO if your procmail doesn't support ^TO_
  :0c # use c only if you want to forward a copy and file the original later
  * ^TO_(important|urgent)|^From:.*(important|urgent)\.com
  {
   :0h
   FROMANDSUBJECT=|formail -XFrom: -XSubject:

   :0fwh
   | formail -I"From: furu009.com" -I"Subject: forwarding to pager" \
         -I"To: 0399999999(_at_)docomonet(_dot_)or(_dot_)jp" ; echo 
"$FROMANDSUBJECT" ; echo

   :0
   ! -t
  }