procmail
[Top] [All Lists]

Re: looking for a pager forwarder

1996-11-26 10:09:26
On Tue, 26 Nov 1996 14:59:41 +0100 (NFT), Thomas Adams 
<finc27(_at_)zx2(_dot_)HRZ(_dot_)Uni-Dortmund(_dot_)DE> said:

    TA> So basically it should process all mailinglist mails like it
    TA> normally does and forward the rest to a specific address, say
    TA> a(_at_)b(_dot_)c(_dot_)d As the gateway transmits only a certain part 
of the
    TA> Subject: line a bit of beautifying (i.e. prepending the From:
    TA> to the Subject: line and cutting off all characters after the
    TA> xth position) wouldn't hurt.

    TA> Anyone out there who did this before?

I certainly don't think it's optimal, since I did the core work *ages*
ago, when I was but an egg.  For example, rather than running the
message through sed to selectively strip headers, I'd recommend trying
formail exclusively.  Then again, I like having the sed script rip out
quoted and blank lines, and attributions, so maybe it's not so silly;
it'd be simpler with formail, though.

page-app just sticks the pager number into the beginning of the body
of the message, which is how our (homebrew) pager gateway wants
things.  YMMV.

    -jml


= /etc/procmailrcs/pageme ================
MYALIAS=pageme(_at_)soils(_dot_)umn(_dot_)edu
HOME=/home/dept/me
ORGMAIL=/usr/spool/mail/me
PAGER=pager(_at_)my(_dot_)pager(_dot_)service(_dot_)dom 
MAILDIR=$HOME/mail       # You'd better make sure it exists
LOGFILE=$MAILDIR/pager.log
LOCKFILE=$HOME/.lockmail.page
SCRIPTDIR=/etc/procmailrcs/scripts

# Un/comment to dis/enable external sends... 
#   eg, when you go on vacation
#PAGER=Me

PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin:$HOME/bin:
SHELL=/bin/sh

:0 Bc
* ^\(This file must be converted with BinHex 4.0\)$
SUBJECT=|formail -x "Subject: "

  # Send autoreply to sender
  :0 Ac
  | (formail -rt -I "Subject: Rejected submission:$SUBJECT" ; \
      echo [ This is an automated reply ] ; \
      echo "" ; \
      echo Your recent submission contained a BinHexed enclosure, and is not ; \
      echo acceptable for automatic mailing into our pager system. ; \
      echo "" ;\
      echo Please remember to hold down the "Shift" key when you press F5.;\
      echo "" ;\
    ) | $SENDMAIL -oi -t

  # Send a copy to pager user
  :0 Ac
  | formail  -I "To: me" -I "Subject: Rejected submission:$SUBJECT" \
    | $SENDMAIL -oi -t
   
  # And log it
  :0 A
  $DEFAULT

## Handle failed pages
#
:0
*^From(_dot_)*service(_at_)my(_dot_)pager(_dot_)service(_dot_)dom
{
    :0B
    *^[-0-9]+: Not sent due to NO_.+
    $ORGMAIL

    :0B
    *^_NO_ page has been sent.
    $ORGMAIL
}

## The guts - strip most of the headers and 
#  mail the body to the pager application, *not* CC'ing ourselves.
#
#  We have 160-character service - the "dd" filter allows for a
#  maximum message, plus the pager ID (9 characters), plus a character.
#
:0c
* ^TOpageme
|(formail \
    | sed -f $SCRIPTDIR/page-hdr \
    | sed -f $SCRIPTDIR/page-app \
    | sed -e 's/^From .*\([0-9][0-9]:[0-9][0-9]\):[0-9][0-9].*/At \1/' \
    | formail -I "From: $MYALIAS" -I "To: $PAGER" \
   )|$SENDMAIL -oi -t $PAGER

## Make a copy in our pagerlog, and let it trickle through to our
#  default inbox as well. 
:0c
pagerlog


= /etc/procmailrcs/scripts/page-app ================
1i\
AAA-CCCC


= /etc/procmailrcs/scripts/page-hdr ================
# $Id$
#
# Rework RFC822 mail messages for emailing to pager
#
# Drop signatures
/^-- *$/,$ { 
 /.*/d
}
# Drop attributions
/^$/,$ {
 /^The dynamic and resourceful John Ladwig commented:/d
 /^You said [0-9][0-9]:[0-9][0-9] [AP]M .*:/d
}
/^$/d
# Strip or modify mail headers
1,/^$/ {
s/^From:[        ]*\("*\([^<"][^<"]*\)"*\) *\(<[-_(_at_)A-Za-z0-9\(_dot_)]*>\)* 
*\((\([^)]*\))\)*/(\2\5)/
 /^Subject:[    ]*/d
 /^Submitted by:[       ]*/d
 /^Content-.*:[         ]*/d
 /^B*[Cc][Cc]:[ ]*/d
 /^Apparently-To:[      ]*/d
 /^Date:[       ]*/d
 /^Mime-.*:[    ]*/d
 /^MIME-.*:[    ]*/d
 /^In-Reply-To:[        ]*/d
 /^Posted-Date:[        ]*/d
 /^Reply-To:[   ]*/d
 /^Resent-.*:[  ]*/d
 /^To:[         ]*/d
 /^X-.*:[       ]*/d
 /^Date-Received:[       ]/d
 /^Errors-To:[   ]/d
 /^Message-I[Dd]:[       ]/d
 /^Nf-From:[     ]/d
 /^Nf-I[dD]:[    ]/d
 /^Path:[        ]/d
 /^Posting-Version:[     ]/d
 /^Received:[    ]/b sw
 /^References:[  ]/d
 /^Relay-Version:[       ]/d
 /^Return-Path:[        ]/d
 /^Status:[      ]/d
 /^Xref:[        ]/d
 /^[    ]/{
        x
        /^NG/{
                x
                d
        }
        x
}
x
s/.*//
x
}
b
: sw
s/.*/NG/
h
d
s/****/---------------------/

= end of enclosures ================

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