Как можно получить вывод STDERR процесса sendmail в переменную? Решение нужно для Windows.
Код | sub send_by_sendmail { my $self = shift; my $return; if ( @_ == 1 and !ref $_[0] ) { ### Use the given command... my $sendmailcmd = shift @_; Carp::croak "No sendmail command available" unless $sendmailcmd; ### Do it: local *SENDMAIL; open SENDMAIL, "|$sendmailcmd" or Carp::croak "open |$sendmailcmd: $!\n"; $self->print( \*SENDMAIL ); close SENDMAIL; $return = ( ( $? >> 8 ) ? undef: 1 ); } else { ### Build the command... my %p = $self->_unfold_stupid_params(@_); $p{Sendmail} = $SENDMAIL unless defined $p{Sendmail}; ### Start with the command and basic args: my @cmd = ( $p{Sendmail}, @{ $p{BaseArgs} || [ '-t', '-oi', '-oem' ] } ); # SetSender default is true $p{SetSender} = 1 unless defined $p{SetSender}; ### See if we are forcibly setting the sender: $p{SetSender} ||= defined( $p{FromSender} ); ### Add the -f argument, unless we're explicitly told NOT to: if ( $p{SetSender} ) { my $from = $p{FromSender} || ( $self->get('From') )[0]; if ($from) { my ($from_addr) = extract_full_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 } else { ### parent $self->print( \*SENDMAIL ); close SENDMAIL || die "error closing $p{Sendmail}: $! (exit $?)\n"; $return = 1; } } return $self->{last_send_successful} = $return; }
|
|