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/lace";
+my $HOME="/home/short";
+# Mail-Alias-1.12 defaults to "/etc/mail/aliases" which does not exist on RedHat sendmail-8.12.5-7
+# Mail-Alias-1.12 will clutter $_ !
+my @addr_addon=(Mail::Alias->new("/etc/aliases")->exists("sentout") ? ("sentout") : ());
my $opt_F;
sub FromAddress
{
);
my $opt_b;
+my $opt_Q;
+my $opt_q;
my $opt_t;
our $opt_f;
#my $opt_F; # declared before &FromAddress already
my @ARGV_save=@ARGV; # for non-bm mode
die if !Getopt::Long::GetOptions(
"b=s" ,\$opt_b,
+ "Q:s" ,\$opt_Q,
+ "q:s" ,\$opt_q,
"t" ,\$opt_t,
"f=s" ,\$opt_f,
"F=s" ,\$opt_F,
|| grep({ File::Basename::basename($0) eq $_; } "newaliases","mailq","smtpd","hoststat","purgestat")
# -bm: Deliver mail in the usual way (default).
|| (defined($opt_b) && $opt_b ne "m")
+ || defined $opt_q # MD_QUEUERUN
+ || defined $opt_Q # MD_QUEUERUN
) {
@ARGV=@ARGV_save;
sendmail_orig_exec();
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
}
# "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;
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;
}