procmail
[Top] [All Lists]

unsubscribe

1999-12-13 12:07:03



------------------------------------- 
FREDERIC TRUDEAU
Service aux Membres / Members Service                              
CAM Internet http://www.cam.org                                    
Tel   : (514) 529.3000 x.233                                       
Fax   : (514) 440.0440
----------------------

On Mon, 13 Dec 1999, Rik Kabel wrote:

josh said:
My Cell phone allows emailed text messages, but only of size 140 char. or
less.  This is great, and procmail allows me to forward certain emails to my
phone, but it'd be nice to get the WHOLE email. :)  splitting it into
several messages would allow me to get around this problem.

Originally I was trying to split the message with the command 'split' but
was having problems as you can see.  I'm really quite new to all this.

Just because you _can_ send your mail to your phone doesn't mean it
makes sense to send complete messages to it. Among other things, it
leaves you open to some very annoying pranks by friends.

Also consider how you will handle mime messages. More and more
mailers use mime encodings for even simple text. Sending complete,
mime-encoded binaries to your handset may not be a good thing.

Perhaps you only need to send the first part of the message, along
with sender and subject information.

If that is sufficient, perhaps the following will serve as a guide.
This is designed to page me during acceptable hours iff I am not
online. It handles some mime messages, and strips quoted text. Before
you can use it, you have to:
      1. Remove ## comments, including leading whitespace, on
         condition lines.
      2. Figure out how to determine if you are online, or remove
         the test.
      3. Figure out how to specify pagehours, or remove the test.
      4. Change the length determination/extract to fit your needs.
      5. Determine if you should use print, as I do, or echo.

It has some warts, but it works well enough for me.

  :0 c                        ## make a copy, and
  * pagesms ?? .              ##  if an sms paging destination is defined
  * $ hour ?? $pagehours_     ##  and it ain't the middle of the night
  * ! online ?? () still      ##  and we are not online still
  { pagebody="no text"        ##  shrink and forward the copy like this:
    oldmetas=SHELLMETAS SHELLMETAS      ##  disable SHELLMETAS
    :0 B f b w i                        ##  first,
    * ^>                                ##   if there are any >quoted lines
    | sed -e '/^ *>/d'                  ##   remove them
    SHELLMETAS=oldmetas                 ##  and restore SHELLMETAS
    :0 B                                ##  if
    * H ?? ^content-type:.+multipart    ##   it is a multipart message
    * ^content-type:.+text/plain(.*$)+\ ##   with at least one plain part
      [  ]*$(([  ]*$)*)*\/[^  
].*$(.*$)?(.*$)?(.*$)?(.*$)?(.*$)?(.*$)?(.*$)?(.*$)?
    { pagebody=$MATCH }                 ##   and save them here
    :0 E B                              ##  else
    * ^^([  ]*$)*[  ]*\/[^  
].*$(.*$)?(.*$)?(.*$)?(.*$)?(.*$)?(.*$)?(.*$)?(.*$)?(.*)?
    { pagebody=$MATCH }                 ##   and save them here
    :0                                  ##  then trim off
    * MATCH ?? ^^\/((([^-]|-[^-]).*)?$)* ## sigs and mime part slop
    * MATCH ?? ^^\/(.*$)*.*[^  ]        ##   and trailing whitespace
    { pagebody=$MATCH }                 ##   and resave
    smsmaxmsg=200                       ## longest ShortMessageService msg
    sms10=.\$*.\$*.\$*.\$*.\$*.\$*.\$*.\$*.\$*.\$* ## 10 msg characters
    sms100=$sms10$sms10$sms10$sms10$sms10$sms10$sms10$sms10$sms10$sms10 ## 100
    :0                                  ##  NOTE: adjust $sms100$sms100 to fit
    * $ pagebody ?? 1^1 > $smsmaxmsg    ##   if pagebody is longer than 
allowed
    * $ pagebody ?? ^^\/$sms100$sms100  ##   cut it at 200 characters
    { pagebody=$MATCH }                 ##  and save them here
    :0 f b w i                          ##   then
    | print -- "$pagebody"              ##   replace body with $pagebody
    :0                                  ##   and then
    ! -f "$efr" -- $pagesms             ##   page it
  }                                     ##  done with copy

-- 
Rik Kabel          Old enough to be an adult              
rik(_at_)netcom(_dot_)com