How to grab header off outgoing message?

How to grab header off outgoing message?

Post by Ed Moo » Sun, 05 Mar 1995 04:17:03



I'm using a trivial shell script to uuencode and mail a file:

uuencode $1 $1 | mailx -s $1 $2

I would like to keep a log file of the message headers so I'll know what
I mailed to whom and when.  Is there some way to capture the header off
the message?

Thanks,

Ed Moore
Hewlett-Packard
Vancouver, WA, USA

 
 
 

How to grab header off outgoing message?

Post by Tony Nugen » Wed, 08 Mar 1995 14:51:25



>I'm using a trivial shell script to uuencode and mail a file:
>uuencode $1 $1 | mailx -s $1 $2
>I would like to keep a log file of the message headers so I'll know what
>I mailed to whom and when.  Is there some way to capture the header off
>the message?

The best way that I can think of is to point the sendmail
variable in your ~/.mailrc file to a script that will grep out
what you want into a file then send the complete message to
your actual /full/path/sendmail program.

In fact, if you do this you can process all your messages in all
sorts of ways before they are actually sent.  I use this method
to append random signatures and quotes to my email (and random
sigs to my usenet postings).

You can also save ALL your outgoing messages by setting the
record variable in ~/.mailrc to a filename, eg:

========8<----insert-crowbar-here------------------------------
# ~/.mailrc
#...
set folder='mail'
set outfolder='mail'
set record='+outbox'
========8<----insert-crowbar-here------------------------------

However, as you are using an actual shell script to do this
anyway, why not do something like this:

========8<----insert-crowbar-here------------------------------
#!/bin/sh
echo "To: " $2       > /tmp/uu.$$
echo "Subject: " $1 >> /tmp/uu.$$
echo "From: " [your_email_address] >> /tmp/uu.$$
uuencode $1 $1      >> /tmp/uu.$$
grep [whatever_string] /tmp/uu.$$ >>! ~/outmailheaders
sendmail             < /tmp/uu.$$
rm /tmp/uu.$$
========8<----insert-crowbar-here------------------------------

(Completely off the top of my head... correct as necessary).

This sends the message directly to sendmail, bypassing mailx
altogether.  Much more efficient (although it does use a
temporary file).

Cheers
Tony
          _______________________________________________________
  _______|      Tony Nugent    |       Griffith University       |______
  \      |                     | Brisbane, Queensland, Australia |     /
   \     |-------------------------------------------------------|    /

   /     |_______________________________________________________|    \
  /__________)                                               (_________\

 
 
 

How to grab header off outgoing message?

Post by Bill Marc » Wed, 08 Mar 1995 00:10:55



>I'm using a trivial shell script to uuencode and mail a file:

>uuencode $1 $1 | mailx -s $1 $2

>I would like to keep a log file of the message headers so I'll know what
>I mailed to whom and when.  Is there some way to capture the header off
>the message?

You could simply add this to the script:
echo $1 $2 `date` >> logfile

--

"There was an old woman who lived in a shoe...
and boy, did it stink in there!"