Article View: comp.mail.mh
Article #1943Automatically Fcc'ing the message's recipient
From: Tom Christiansen
Date: Thu, 14 Dec 1989 02:40
Date: Thu, 14 Dec 1989 02:40
76 lines
2583 bytes
2583 bytes
I recall someone once asking whether they could make all their outgoing
mail get automatically Fcc'd to the folder of the name of the recipient.
Here's a way to do it for all outgoing mail (like repl, comp, ...). The
way it works is this: you install THIS as your postproc and put an entry
in your mh_profile like this:
postproc: post-fcc
Now anyone in the To, Cc, or Bcc list (or Resent-foo) will get a copy
in the folder by their login name. MH will make these hardlinks, so
it's no more costly (very nearly the truth) than the single +outbox
copy you may be used to.
Put the following script somewhere in your path, call it "post-fcc", and
make it executable. It assumes that the real post is in
/usr/local/mh/lib/post, so you'd better make sure it is or alter the path
on the exec. It groks addresses filled with @'s and !'s and %'s. If
you're used to mailing 'jimbo' as your private alias for 'orosz', you'd
better make a symlink such that jimbo->orosz, because this happens before
aliasing.
This is a perl script. I run perl 3.0p6, mh 6.6, and it works for me.
--tom
#!/usr/bin/perl
$file = $ARGV[$#ARGV];
$tmp = "$file.$$";
open (file, "<$file") || die "can't read $file: $!";
open (tmp, ">$tmp") || die "can't write $tmp: $!";
select(tmp);
while (<file>) {
last if /^-*$/;
if (/^((resent-)?(to|b?cc)):\s*(.+)/i) {
$header = $1;
do parse($4);
} elsif (/^\s+(.*)/ && $header) {
do parse($1);
} else {
$header = '';
}
print;
}
print "Fcc: ", join(', ', @fccs), "\n" if $#fccs >= 0;
print "\n";
print while <file>;
close file;
close tmp;
rename($tmp,$file);
exec '/usr/local/mh/lib/post', @ARGV;
sub parse {
local($_) = @_;
for (split(/\s*,\s*/)) {
s/.*<([^>]+)>.*/$1/;
s/@.*//;
s/.*!//;
s/\(.*\)//;
s/\s//g;
push(@fccs,'+'.$_) unless $seen{$_}++;
}
}
Tom Christiansen {uunet,uiucdcs,sun}!convex!tchrist
Convex Computer Corporation tchrist@convex.COM
"EMACS belongs in <sys/errno.h>: Editor too big!"
Technical Details
Message-ID:
<3943@convex.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!convex!convexe!tchristShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!convex!convexe!tchrist From: tchrist@convexe.uucp (Tom Christiansen) Newsgroups: comp.mail.mh Subject: Automatically Fcc'ing the message's recipient Keywords: fcc perl postproc Message-ID: <3943@convex.UUCP> Date: 14 Dec 89 02:40:03 GMT Sender: news@convex.UUCP Reply-To: tchrist@convex.Com (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 76