At 03:44 +0200 10 Dec 1999, Mikko H�nninen <[EMAIL PROTECTED]> wrote:
> Mike Bell <[EMAIL PROTECTED]> wrote on Thu, 09 Dec 1999:
> > Would it be possible to arrange for the contents of the from: header in sent
> > mail to be exported to the sendmail command, maybe as an environment
> > variable? I'd like to have my envelope-sender mirror the address I use in my
> > from: line, since I send email from multiple accounts.
> 
> Sounds like something that could be done with a wrapper script, invoked
> instead of the real sendmail command to first parse the email, set the
> environment variable, and then call sendmail.
> 
> I wonder if anyone's done anything like this?

I'm doing almost exactly that.  But instead of putting the address in
the environment, I just add the proper arguments to the command line
when calling the real sendmail.  Perl script attached, although it needs
to be modified, since it basically has my $alternates setting hard coded
into it.

-- 
Aaron Schrab     [EMAIL PROTECTED]      http://www.execpc.com/~aarons/
 If you want to program in C, program in C. It's a nice language. I
 use it occasionally...   :-)
   --Larry Wall
#!/usr/bin/perl

$debug = 0;
$sendmail = '/usr/sbin/sendmail';
@args = @ARGV;

if ($debug) {
  open (STDERR, ">>/tmp/sm.log");
  print STDERR join(':', @args), "\n";
}

goto SEND if (grep /^-f/, @args);

while (<STDIN>) {
  push @l, $_;
  last if (/^$/);
  if (/^From:\s*(.*)/) {
    $from = $1;

    if ($from =~ /((aarons|ats|bofh|listmaster|lsm-help|procmail|Aaron\.Schrab)
                        \@([a-z0-9-]+\.)*execpc\.com|
                      (aaron(s|\+[a-z0-9+-]+)?|(post|web)master|ats|root|bofh)
                        \@schrab\.com
                  )/ix)
    {
      print STDERR "Found address $1\n" if $debug;
      unshift @args, "-f$1";
      last;
    }
  }
}

SEND:

if ($debug) {
  print STDERR "Command: $sendmail ", join (' ', @args), "\n";
  print STDERR @l, <STDIN>;
  exit;
}
else {
  open (S, "|-") or exec $sendmail, @args;
  print S @l, <STDIN>;
  close S;
  exit ($?);
}


# vim: ai si

Reply via email to