I am fairly new to scripting languages of any sort, but I have been
trying to get procmail working, since it appears it should save me a
lot of time. However, I have found my limits and can't seem to either
word, or order the ideas correctly for the recipe to work.
What I am trying to do is take mail from a mailing list, checking to
see if it is from a certain user, checking to see if it has a certain
subject, and if so... to put it into a file, not necessarily a folder.
Specificly, my problem lies in two areas. First, I know how to get the
recipe to copy the file so I retain the original in my inbox, but I
don't know how to get it to put the file anywhere other than in my
$MAILDIR.
Just specify where you want the file put. Let's say you want any incoming
email with the word 'RISC' in it to go into the file $HOME/RISC, just do
the following:
# See if the incoming email has the word 'RISC' in the 'Subject:'
# header. If so, stick it in the file "$HOME/RISC". We have
# D argument set, because in this example we are checking for the
# presence of the word 'RISC' and not the word "[Rr][Ii][Ss][Cc]".
#
:0D:
* ^Subject:.*RISC
$HOME/RISC
Second, is there a way to strip the headers, including the
subject so that the file created just contains the text in the body of
the message?
# Consider the pipe as a filter, feed only the body to the pipe,
# wait for the filter to exit, and make the EGREP case sensitive.
# Now, take that output and CAT it to the file "$HOME/RISC".
#
:0fbwD
* ^Subject:.*RISC
| cat > $HOME/RISC
You could change the '>' in the action line to '>>' to have it append to
the file if you didn't want each new email with 'RISC' in it to CLOBBER
the older one (would also need to make it use a lockfile).
I would also like to know if there is a way for the recipe to check to
see if the file already exists, so it can remove that file before it
creates the new one.
Do something along these lines...
# Check to see if the file "$HOME/RISC" exists, if it does, delete
# it.
:0
? test -f $HOME/RISC
{
| rm $HOME/RISC
}
Thanks in advance.
Willie Williams | airborne(_at_)wizvax(_dot_)net |
http://www.wizvax.net/airborne
Lates!
---------------------------------------------------------------------------
Tim <bodysurf(_at_)pobox(_dot_)com>
mailto:bodysurf(_at_)pobox(_dot_)com
Finger bodysurf(_at_)pobox(_dot_)com for my PGP public key (Bits 1024/KeyID
09DA5C49).
PGP Key FPrint (09/03/94): 4C 97 F1 FA 70 55 68 91 49 D1 AD F2 DD 63 0C 15
---------------------> Please PGP encrypt your email <---------------------