my %p = @_; $p{Sendmail} ||= "/usr/lib/sendmail"; ### Start with the command and basic args: my @cmd = ($p{Sendmail}, @{$p{BaseArgs} || ['-t', '-oi', '-oem']}); ### See if we are forcibly setting the sender: $p{SetSender} = 1 if defined($p{FromSender}); ### Add the -f argument, unless we're explicitly told NOT to: unless (exists($p{SetSender}) and !$p{SetSender}) { my $from = $p{FromSender} || ($self->get('From'))[0]; if ($from) { my ($from_addr) = extract_addrs($from); push @cmd, "-f$from_addr" if $from_addr; } } ### Open the command in a taint-safe fashion: my $pid = open SENDMAIL, "|-"; defined($pid) or die "open of pipe failed: $!\n"; if (!$pid) { ### child exec(@cmd) or die "can't exec $p{Sendmail}: $!\n"; ### NOTREACHED }