[comp.unix.questions] tricky mail aliases

drascic@ecf.UUCP (09/12/87)

I would like to organize my correspondance so that all letters to and
from a particular person would be stored in a single file.  Is there any
way to do this using "set record", so that a letter to joe@somewhere would
be saved in the file mbox.joe?

I tried using an alias redirection such as the one suggested for those who
would like to be able to print letters without saving them.  I tried using
	alias joe joe@somewhere "|cat>>mbox.joe"
but then found out that the aliases are made backwards, so that this was
treated as "| cat >> mbox.joe joe@somewhere".  It would save the local
copy, but nothing would be sent.

I tried reversing the order:
	alias joe "|cat>>mbox.joe"  joe@somewhere
but this didn't work either.

Any suggestions?

dhesi@bsu-cs.UUCP (09/12/87)

In article <264@mv06.ecf.toronto.edu> drascic@ecf.toronto.edu (SpIKe) writes:
>I would like to organize my correspondance so that all letters to and
>from a particular person would be stored in a single file.

The following solution works under 4.3BSD, using the Berkeley mail
program.

1.   In .mailrc, put the line:

     alias tojoe "|sendtojoe"

2.   Create an executable script called "sendtojoe" that contains:

     #! /bin/sh
     tee -a mbox.joe | mail joe

To avoid an infinite loop, I used "tojoe" as the initial address, and
later "joe" gets used for the actual delivery.  The "-a" option to tee
tells it to append to the argument file.

You might try just using "joe" everywhere, but replacing the "mail" in
the script (which refers to /usr/ucb/mail) with "/bin/mail" to avoid an
infinite loop.  I didn't try this.

A much better solution is to use the MH mail system, and specify 
"Fcc: +inbox" in your template.  Then all mail outgoing is saved in the
"inbox" folder, and you can later refile as necessary with

     refile `pick +inbox -to joe -or -from joe` +joe

which searches for all mail to or from Joe and refiles it in a folder
called "joe".

None of this is guaranteed to work under System V.
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi

jai@im4u.UUCP (Jai Srinivasan) (09/13/87)

In article <264@mv06.ecf.toronto.edu> drascic@ecf.toronto.edu (SpIKe) writes:

>I would like to organize my correspondance so that all letters to and
>from a particular person would be stored in a single file.  Is there any
>way to do this using "set record", so that a letter to joe@somewhere would
>be saved in the file mbox.joe?

That can be done on 4.2 BSD with the standard mail program by:
	
	alias joe joe@somewhere +mbox.joe

in your .mailrc file.  The +mbox.joe mails the message to a folder
(file), which is stored in a directory specified by the variable
"folder".  This variable can be set in .mailrc too, eg:

	set folder folders

will cause all your mail folders to be saved in the directory
$HOME/folders.  You can save incoming mail from joe by typing 
"s <message_list> +mbox.joe".  To browse through the old mail
to/from joe, use the command `mail -f +mbox.joe'.

The one annoying feature of this is that when joe replies to a message
you send him, a cc will be sent to "+mbox.joe" unless he removes that
from the cc list.  That causes the message he sends to be put in a file
mbox.joe in his folder directory, or to a file +mbos.joe in his current
directory, if his variable `folder' is not set.  The mail program
should have made file aliases blind or should have a way to specify a
bcc (blind carbon copy) list with an alias.

--------
Jai Srinivasan, UUCP: {gatech,harvard,ihnp4,pyramid,seismo}!ut-sally!im4u!jai
ARPA:  		      jai@im4u.UTEXAS.EDU, jai@sally.UTEXAS.EDU

-----------------------------

billw@killer.UUCP (09/16/87)

drascic@ecf.toronto.edu (SpIKe) in <264@mv06.ecf.toronto.edu>:

> I would like to organize my correspondance so that all letters to and
> from a particular person would be stored in a single file.  Is there any
> way to do this using "set record", so that a letter to joe@somewhere would
> be saved in the file mbox.joe?

I once managed to create a system in a berkmail clone whereby all my outgoing
mail, instead of being placed in an outbound file, would be placed in an
outbound DIRECTORY, with the current date and time used for the filename. I
am sure it would be possible to file under the name of the recipient, but I
certainly wouldn't know how: you would have to somehow filter the name of
the addressee out of the message.
-- 
Bill Wisner				..ihnp4!killer!billw

"An it harms none, do what thou will."
Everything in this message may be wrong.

allbery@ncoast.UUCP (09/18/87)

As quoted from <1137@bsu-cs.UUCP> by dhesi@bsu-cs.UUCP (Rahul Dhesi):
+---------------
| A much better solution is to use the MH mail system, and specify 
| "Fcc: +inbox" in your template.  Then all mail outgoing is saved in the
| "inbox" folder, and you can later refile as necessary with
| 
|      refile `pick +inbox -to joe -or -from joe` +joe
| 
| which searches for all mail to or from Joe and refiles it in a folder
| called "joe".
+---------------

Your first example will work with System V mailx.

As for this MH stuff:  why not "Fcc: +joe" to begin with?
-- 
	    Brandon S. Allbery, moderator of comp.sources.misc
  {{harvard,mit-eddie}!necntc,well!hoptoad,sun!mandrill!hal}!ncoast!allbery
ARPA: necntc!ncoast!allbery@harvard.harvard.edu  Fido: 157/502  MCI: BALLBERY
   <<ncoast Public Access UNIX: +1 216 781 6201 24hrs. 300/1200/2400 baud>>
All opinions in this message are random characters produced when my cat jumped
(-:		      up onto the keyboard of my PC.			   :-)

ken@cs.rochester.edu (Ken Yap) (09/18/87)

||      refile `pick +inbox -to joe -or -from joe` +joe
|| 
|As for this MH stuff:  why not "Fcc: +joe" to begin with?

Because you might want to type a message quickly with "prompter" and
leave the Fcc: line as is in the template, then refile all joe messages
much later when you have a whole bunch. That's the nice thing about
MH, you can do it any way you fancy, so let's not get religious. 1/2 :-).

	Ken