my $fh; if( ! open($fh, '>>', 'XXX') ){ # log error } else { print $fh $email_message."\n-------------\n"; close $fh } $mailprog = '/usr/sbin/sendmail'; open (MAIL, "|$mailprog -t >> XXX 2>&1"); print MAIL $email_message; if( ! close (MAIL) ){ # replace this with your error-logging facility print "Content-type: text/html\n\n"; print "error, command failed with ".($?>>8)."
\n" print "message was:
\n${email_message}
\nEND message
\n"; } else { # EDIT: wrapped this in else! print "Location: application-submitted \n\n"; }