procmail
[Top] [All Lists]

Re: Sending notification of new mail

1997-10-16 12:33:04
Peter Galbraith wrote,

| I have a few users that want to keep mail on my machine for privacy (no
| .forward file), but rarely log-on to see if they have new mail.  Instead of
| getting them using a POP client to see if they have new mail, I thought I'd
| set up a filter that emails a one-liner message to their corporate addresses
| when they get new mail. e.g.
| 
|  You have mail on mixing from: Peter S Galbraith 
<galbraith(_at_)mixing(_dot_)qc(_dot_)dfo(_dot_)ca>
| 
| Can anybody provide a simple recipe?  I tried stuff like:
| 
| FROM='formail -x From:'
| :0c
| * ^TOrhogee
| | mail -s "$FROM" other_account
| 
| 
| But the 'formail' command doesn't get invoked ...

Well, you tilted the ticks the wrong way.  It should be

 FROM=`formail -x From:` # or -zx if your formail groks -z

| ... and I don't want to send a copy of the mail but rather just a single
| line message.  How do I:
| 
|  - Put the From: line content into a variable?
|  - Invoke a command that doesn't really filter mail to send a one-line
|    message containing the above variable?
|  - Continue processing the message to the normal spool file even after
|    matching the above condidtions?

Let's start from scratch; brackets enclose space and tab or caret, space,
and tab:

  :0
  * ^From:[     ]*\/[^  ].*
  { FROM=$MATCH }

  :0
  * ^Subject:[  ]*\/[^  ].*
  { SUBJECT=$MATCH }

  :0cir
  | echo "You have mail waiting on mixing:" ; \
    echo " from: $FROM" ; \
    echo " subject: $SUBJECT" | mail -s "$SUBJECT" other_address

Or here's another approach that just uses the original head:

 :0c # fork clone so that original message is untouched
 {
  :0bfir
  | echo \
  "Mail with the aforementioned subject and sender is waiting on mixing."

  :0
  ! other_address
 }

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