From ad512beb433a9c57a944d4e7abcd1681289d88b8 Mon Sep 17 00:00:00 2001 From: short <> Date: Sun, 6 Oct 2002 21:32:15 +0000 Subject: [PATCH] +@addr_addon: Additional mail aliases to Bcc to - defaults to system alias "sentout" (if exists) Fixed "From" filling if no From-style headers exist Fixed missing header<->body newline delimiter (it worked?) --- perlmail-sendmail | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/perlmail-sendmail b/perlmail-sendmail index 3b50a0d..5f6a070 100755 --- a/perlmail-sendmail +++ b/perlmail-sendmail @@ -12,9 +12,12 @@ use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG); require Mail::Header; require Mail::Address; require File::Basename; +require Mail::Alias; my $sendmail_orig=(-x ($_="/usr/sbin/sendmail-orig") ? $_ : "/usr/sbin/sendmail"); my $HOME="/home/short"; +# Mail-Alias-1.12 defaults to "/etc/mail/aliases" which does not exist on RedHat sendmail-8.12.5-7 +my @addr_addon=(Mail::Alias->new("/etc/aliases")->exists($_="sentout") ? ($_) : ()); my $opt_F; sub FromAddress { @@ -216,13 +219,13 @@ my $from_headername; my $muttrc_From=parseone(scalar muttrc_get("from")); # may get undef()!; parseone() may be redundant $muttrc_From=$muttrc_From->address() if $muttrc_From; $opt_f=undef() if defined($opt_f) && $muttrc_From && lc($opt_f) eq lc($muttrc_From); - my @from_val; for (@h_from) { $from_headername=$_; # leave last item in $from_headername - last if @from_val=$head->get($from_headername); - } - @from_val=map({ ($_->address()); } map({ (Mail::Address->parse($_)); } @from_val)); - $from_headername=undef() if !(1==@from_val && $muttrc_From && lc($from_val[0]) eq lc($muttrc_From)); + next if !(my @from_val=$head->get($from_headername)); + @from_val=map({ ($_->address()); } map({ (Mail::Address->parse($_)); } @from_val)); + $from_headername=undef() if !(1==@from_val && $muttrc_From && lc($from_val[0]) eq lc($muttrc_From)); + last; + } # fallthru with $from_headername remaining set if last headername did not exist # now $from_headername contains the header name to be replaced w/substituted value } @@ -253,6 +256,7 @@ for my $rcpt (@rcpts) { # "From/Resent-From" should be handled by our &FromAddress push @ARGV,"-F",$opt_F if defined $opt_F; push @ARGV,$rcpt->address() if defined $rcpt; + push @ARGV,@addr_addon; local $SIG{"PIPE"}=sub { die "Got SIGPIPE from ".sendmail_show(); }; local *SENDMAIL; @@ -265,7 +269,7 @@ for my $rcpt (@rcpts) { sendmail_orig_exec() if !$pid; # child } $head->print(\*SENDMAIL); - print "\n"; # Mail::Header->print() eats the empty line but it doesn't print it + print SENDMAIL "\n"; # Mail::Header->print() eats the empty line but it doesn't print it if (defined($stdin_body)) { print SENDMAIL $stdin_body; } -- 1.8.3.1