procmail
[Top] [All Lists]

Re: Create new mail with procmail

1997-01-14 10:47:38
    > I need a script that notifies my pager on incoming mails. I tried a cript
    > like :
    > :0 c
    > ! my_pager(_at_)paging(_dot_)com
    > 
    > but it wouldn\xB4t work. So what I really need is a script that
    > creates a new mail using the old subject and leaving the body
    > blank (directed to my_pager(_at_)paging(_dot_)com).  Any ideas ? Thanks a 
lot
    > in advance !! Please reply to tihmann(_at_)on-luebeck(_dot_)de

Easy.

    # If the mail is *directly* to me, and not from a mailing list, and
    # not from a deamon, then page me with the subject and no message.
    # In other words, only important mail from a human directly to me.
    # (Uses procmail-3.11 syntax)

    # This recipe uses "Mail", the BSD Mail, which is convenient for
    # generating subject-only mail.

    :0 ciw
    * ^TO_$LOGNAME
    * !^Precedence: *(bulk|junk)
    * !^FROM_DAEMON
    * ^Subject: *\/[^ ].*
    | Mail -s "$MATCH" my_pager(_at_)paging(_dot_)com </dev/null

If you don't have "Mail", and wish to feed the mail directly to
Sendmail, use this recipe instead:

    :0 c        # fork a procmail subprocess
    * ^TO_$LOGNAME
    * !^Precedence: *(bulk|junk)
    * !^FROM_DAEMON
    * ^Subject: *\/[^ ].*
    { :0 fiw    # generate a mail 
      | echo "To: my_pager(_at_)paging(_dot_)com" ; echo "Subject: $MATCH" ; 
echo 
      :0        # send the mail
      ! -t
    }

G'luck.

___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks