You must completely read the formail manpage to understand it's operation Let's start with a simple example from my own .procmailrc. I recently left UIUC and my email address used to be <jgross@uiuc.edu>. I knew my old address would go away at some point so I got a new one at <jgross@stimpy.net>.
I didn't want to lose the mail that people were sending to jgross@uiuc.edu and I also wanted to mail them a reminder that my ph alias had changed. Formail comes to the rescue:
# This recipe will take any mail addressed to jgross@uiuc.edu and create an autoreply
# header. The autoreply header will have a To: that is set to the sender of the mail.
# We then extract the To: header and append it to the $HOME/.uiucers file so we have
# a list of who's been using the old address.
# The -r means get a return address. The -x means extract a header.
:0c
* ^TOjgross@uiuc.edu
{
:0c
|formail -r -x "To:" >> $HOME/.uiucers
# This next part will send them a letter containing .uiuc.message which
# tells them I got the letter but to start using jgross@stimpy.net as my address
# The -brt essentially generates an autoreply header.
# I use the -I to add the "correct" From: header
# We then append the .uiuc.message as they body and pipe it through sendmail.
# We also use a backslash to span a line break
# This really does do a lot so don't try to swallow it whole.
:0
| (formail -brt -I 'From: Joe Gross <jgross@stimpy.net>' ; \
cat $HOME/.pick.message) | $SENDMAIL -t
}
Don't worry too much about this. You'll get the hang of formail as we go through other (probabaly simpler) examples.
Back: More complex filtering
Top
Next: vacation with procmail
j g r o s s @ s t i m p y . n e t