The man (Mr. Procmail) wrote:
Hal Wine <hal(_at_)dtor(_dot_)com> wrote:
At 08:15 10/12/95, Professional Software Engineering wrote:
* if not, does anyone have any interest in the (simple) line
remover utility (as C source -- all like 7 lines of it)? I
don't do perl, and I know it could be done a dozen or more
different ways (all of them valid).
It struck me that if you remove the separator line, that you
can simply 'cat' additional header lines into the stream,
which is a LOT easier than having to give formail lots of
options.
Well, formail wouldn't have been called formail, if it wouldn't allow
you to do most anything for mail :-). It can already do what you want,
without lots of options...
:0 hf
* whatever
| $FORMAIL -rt | cat - $HOME/newHeaders
This sends only the headers ('h' option) to first formail to play with
them. Formail's output is the sent to cat, which replicates them, followed
by the new headers. The result is used to replace the original headers
('f' option)
The problem here is that there will be a newline in the middle, which
causes the header to be shortened (procmail determines the new header/body
boundary after having processed each filter).
Try this instead:
:0 hf
* whatever
| $FORMAIL -rt -X "" ; cat $HOME/newHeaders
Okay, but in short, the following isn't unkosher, it just doesn't rely on
age-old UNIX commands (like sed in a previous post):
| ( $FORMAIL -rt -I "Subject: Some new subject" | unblank ;\
mimecode $HOME/ftp/somefile /body:$HOME/ftp/somefile.inf ) ;\
| $SENDMAIL -t
(btw - in real life the last line is actually part of the "mimecode" line,
but I didn't want to linewrap here).
I have bunches of similar recipes, for different files (and with different
subject lines).
unblank is a small program I plinked out to get a line from stdin and send it
to stdout as long as it wasn't blank. mimecode is the program I wrote to
generate MIME encapsulated data, and to create the specific formatted header
lines (with a blank line separator following them).
(Basically, this allows me to send a message with a file attachment (as
recognized by the client software), and a body message giving the user
instructions and some basic information, like how to save it, etc.).
I've got to sit down and implement a few of the things that have been
mentioned here and take a look at them, but all in all, I'm quite thrilled
with this capability I now have (manually responding to redundant EMail
requests has become a drag, and the FTP server at my ISP has been
experiencing load problems for the past month).
Thanks for making procmail, BTW.
(side note: one of the headerlines I might often include is a URL to a home
page, which newer mail client programs are starting to be able to
automatically locate and give links through. A no-brainer for the user.)
--
(margin problems, if any, are due to problems in the interface software)
NetCruisers: ftp://ftp.netcom.com/pub/ps/pse/www/pse_home.html
Home of NCUtil, 3rd-party utility links (including Winsock), and FAQs!
Sean B. Straw / Professional Software Engineering
Post Box 2395 / San Rafael, CA 94912-2395
CompuServe: 72210,521 Internet: PSE(_at_)ix(_dot_)netcom(_dot_)com