Priority: Normal
Current State: No Action Required
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: FoswikiNet, configure
Branches: trunk
When email is configured to use the sendmail mailprogram, adding the "-v" option often returns detailed debugging information. However this ends up logged into the apache error-log, and is not captured by the bin/configure email test function. In addition, should Net.pm be calling sendmail program without using Foswiki Sandbox?
--
GeorgeClark - 06 Mar 2012
Following patch will use
IPC::Run
if available. It seems to capture STDERR and STDOUT just fine.
diff --git a/core/lib/Foswiki/Net.pm b/core/lib/Foswiki/Net.pm
index c382e9f..71a4b65 100644
--- a/core/lib/Foswiki/Net.pm
+++ b/core/lib/Foswiki/Net.pm
@@ -20,6 +20,7 @@ use Assert;
use Error qw( :try );
our $LWPAvailable;
+our $IPCRunAvailable;
our $noHTTPResponse; # if set, forces local impl of HTTP::Response
# note that the session is *optional*
@@ -477,11 +478,28 @@ s/([\n\r])(From|To|CC|BCC)(\:\s*)([^\n\r]*)/$1.$2.$3._fixLineLength($4)/geois;
"====== Sending to $Foswiki::cfg{MailProgram} ======\n$text\n======EOM======\n"
if ( $Foswiki::cfg{SMTP}{Debug} );
- my $MAIL;
- open( $MAIL, '|-', $Foswiki::cfg{MailProgram} )
- || die "ERROR: Can't send mail using Foswiki::cfg{MailProgram}";
- print $MAIL $text;
- close($MAIL);
+ unless ( defined $IPCRunAvailable ) {
+ eval 'require IPC::Run';
+ $IPCRunAvailable = ($@) ? 0 : 1;
+ }
+
+ if ($IPCRunAvailable) {
+ my ( $out, $err );
+ my @cmd = split /\s/, $Foswiki::cfg{MailProgram};
+ require IPC::Run;
+ IPC::Run::run( \@cmd, \$text, \$out, \$err )
+ or die "ERROR: Exit code "
+ . ( $? << 8 )
+ . " ($?) from Foswiki::cfg{MailProgram}";
+ print STDERR "$out" if ($out);
+ print STDERR "$err" if ($err);
+ }
+ else {
+ my $MAIL;
+ open( $MAIL, '|-', $Foswiki::cfg{MailProgram} )
+ || die "ERROR: Can't send mail using Foswiki::cfg{MailProgram}";
+ print $MAIL $text;
+ close($MAIL);
#SMELL: this is bizzare. on a freeBSD server, I've seen sendmail return 17152
#(17152 >> 8) == 67 == EX_NOUSER - however, the mail log says that the error was
@@ -490,10 +508,11 @@ s/([\n\r])(From|To|CC|BCC)(\:\s*)([^\n\r]*)/$1.$2.$3._fixLineLength($4)/geois;
#rego failed completely.
#Sven has ameneded the oops_message for the verify emails to be less positive that
#everything has failed, but.
- die "ERROR: Exit code "
- . ( $? << 8 )
- . " ($?) from Foswiki::cfg{MailProgram}"
- if $?;
+ die "ERROR: Exit code "
+ . ( $? << 8 )
+ . " ($?) from Foswiki::cfg{MailProgram}"
+ if $?;
+ }
}
sub _sendEmailByNetSMTP {
--
GeorgeClark - 07 Mar 2012
These changes were reverted by other Email work. Changing task to "No Action"
--
GeorgeClark - 09 Feb 2015