>% what i'd like to do is have every outbound message saved to a folder
>...
>% save an additional copy to a folder called, eg, sent-today.  that way
>
>As you've seen, there's no stock way to do it right now.

yup.  so i've attached my "solution".  it's a perl script that i've
been using (for two days) in place of sendmail on my system (well,
ultimately it just calls sendmail, but you get the picture).

i have this in my .muttrc file

        set sendmail="/home/andrew/Mail/bin/sendmail -t -oi -oem"

and the attached script in /home/andrew/Mail/bin/sendmail.  it reads
the message from mutt over stdin, intuits a from_ header to stuff into
the send-today mailbox, appends a copy to the send-today mailbox, and
writes out another copy to a temporary file that it immediately
unlink()s.

then it moves stdin out of the way and attaches it to the temporary
unlinked file and execs sendmail.  sendmail reads the message from
stdin (the file with one copy of the message in it) and sends it out.

it works.  i was just hoping for something a little more elegant, like
a way simply to do more than one fcc line.

-- 
|-----< "CODE WARRIOR" >-----|
[EMAIL PROTECTED]             * "ah!  i see you have the internet
[EMAIL PROTECTED] (Andrew Brown)                that goes *ping*!"
[EMAIL PROTECTED]       * "information is power -- share the wealth."
#!/usr/local/bin/perl

$SIG{'INT'} = 'IGNORE';
$SIG{'QUIT'} = 'IGNORE';

$home = "/home/andrew";
$maildir = $home . "/Mail";
$spool = $maildir . "/in.outbound";
$tspool = $maildir . "/.outbound.$$";

$sendmail = "/usr/sbin/sendmail";
unshift(@ARGV, "sendmail");

open(T, "+>$tspool") || warn("T: $@\n");
unlink($tspool) || warn("unlink: $@\n");
select((select(T), $| = 1)[0]);
open(K, ">>$spool") || warn("K: $@\n");

$buffering = 1;
$from = "";
$date = "";

while (<STDIN>) {
    if ($buffering) {
        $buffering = 0 if (/^\s*$/);

        if (/^From +(\S+) +(\S+ +\S+ +\S+ +\S+ \S+)/) {
            $buffering = 0;
            goto have_from;
        }

        if ($from eq "" && /^From:\s*(.*)/) {
            $from = $1;
            $from = $1 if ($from =~ /<([^>]+)>/);
            $from =~ s/\s.*//;
        }

        if ($date eq "" && /^Date:\s*(.*)/) {
            $date = $1;
            $date =~ /(\S+), +(\d+) +(\S+) +(\d+) +([\d:]+)/;
            $date = sprintf("%s %s %2d %-6s %4d", $1, $3, $2, $5, $4);
        }

        if ($buffering == 0 || ($from ne "" && $date ne "")) {
            print(K "From $from $date\n");
            print(K $buffer);
            $buffering = 0;
        }
        else {
            $buffer .= $_;
        }
    }

    print(T);
      have_from:
    print(K) if (!$buffering);
}

print(K "\n");
close(K);

seek(T, 0, 0);
open(STDIN2,"<&STDIN") || warn("dup 1: $@\n");
close(STDIN);
open(STDIN,"<&T") || warn("dup 2: $@\n");

exec($sendmail @ARGV);

Reply via email to