This is a follow-up to my previous post for anyone who might have this problem and find this in the archives.
 
Firstly, the install was done correctly, I just lacked an understanding of the directory hierarchies.

The version used in my original post was the binary distribution of Apache+Perl+modperl
from http://www.perl.com/CPAN/authors/Jeffrey_Baker/ (perl-5_005_02+apache1_3_3+modperl-1_16-bin-bindist1-i386-win32-vc5.zip).  If you run the following command on the server, it will show an increasing value for "Reset Connections" each time the email send fails:
 
 C:\>netstat -s
 
TCP Statistics

  Reset Connections                   = 8

I found old mod_perl list postings from Jun 1998 where the poster had the same problem but no solution.

I found a reference to another build in my mail archives.  I downloaded the Randy Kobes binary distribution from ftp://theoryx5.uwinnipeg.ca/pub/other/ and ran it.  It has Perl-5.6.0, mod_perl-1.23, and Apache_1.3.12.  Even though it does not have everything we need, I set it up to see if the port problem is there.  The problem does not occur with this build.
 
We need Oracle drivers built in for our use, so we decided to do our own build.  It seamed inevitable that we would need to learn to do this.  I've built from source with Perl-5.6.0, mod_perl-1.24, and Apache_1.3.12 and it does not have the problem.  It seams to be OK and the building went better than expected.
 
I have to assume the problem was caused somewhere in the low-level socket code but not sure whose.  The Microsoft web sites indicate patches where made in the TCP code in each NT service pack. 
 
Hope this helps somebody.
 
Chuck Goehring
 
 
 
 
 
 
-----Original Message-----
From: Chuck Goehring <[EMAIL PROTECTED]>
To: mod perl list <[EMAIL PROTECTED]>
Date: Monday, May 15, 2000 10:00 PM
Subject: Problem: Apache/mod_perl/NT host won't close smtp connection

 
 
Having a problem where the connections to an smtp server doesn't seam to close correctly on Windows NT. I've tried two separate mailing modules (MIME::Lite and Mail::Sender). Neither will send a second time without re-starting Apache. The Lite module uses the Net::smtp module and the Sender directly uses a Socket (not IO::Socket). Additional details are listed further down. My general question is: Are there problems with "PERL" Sockets on mod_perl/NT? Since a nearly identical test program works from the PERL.exe command line it seams as if mod_perl is trying to keep the port open or something.
 
Also, there are some directories that came with the Apache/mod_perl binary distribution that have Socket.pm files in them. These directories are perl\lib\MSWin32-x86 and perl\lib\MSWin32-x86\IO. Should they have been copied over the other files in the perl directory tree? Or, put in the startup.cgi(listing is at bottom)? The distribution came with little docs and it was my first mod_perl setup.
 
Any infomation would be greatly appreciated. 
 
 
Chuck Goehring
[EMAIL PROTECTED]
 
Below are more details of the problem I've been having.
----------------------------------------------
Details:
I'm using MIME::Lite to let users email files to other users as part of a document management system. The MIME::Lite package inherits from Net::SMTP (@ISA = qw(Net::SMTP);) and adds the capability to add attachments to the email.
It works fine the first time but gives an error the second time. If I run it external to the site via the perl.exe command line (with use CGI lines removed), it works flawlessly every time. Once the error starts, even leaving it overnight doesn't allow it to work. It acts as though the socket doesn't get closed and can't be reused. Below are the pertinant scripts.
 
----------------------------------------------
MIME::Lite sub to send via smtp:
 
sub send_by_smtp {
 
my ($self, @args) = @_;
# We need the "From:" and "To:" headers to pass to the SMTP mailer:
my $hdr = $self->fields();
my $from = $self->get('From');
my @to = $self->get('To');
# Create SMTP client:
require Net::SMTP;
my $smtp = MIME::Lite::SMTP->new(@args)
or croak "Failed to connect to mail server: $!";
$smtp->mail($from)
or croak "SMTP MAIL command failed: $!";
$smtp->to(@to)
or croak "SMTP RCPT command failed: $!";
$smtp->data()
or croak "SMTP DATA command failed: $!";
# MIME::Lite can print() to anything with a print() method:
$self->print($smtp);
$smtp->dataend();
$smtp->quit;
1;
}
 
----------------------------------------------
The Error from MIME::Lite:
[Sun May 14 16:20:10 2000] -e: Failed to connect to mail server: Bad file descriptor at c:/apache/cgi-perl/test_sa_mime.cgi line 38 (Line 38 contains $SMTPRetVal = $msg->send_by_smtp($SMTPhost, Timeout => 40);
----------------------------------------------
Configuration:
Windows NT service pack 4
Apache 1.3.3 with mod_perl 1.16 binary from www.apache.org
cgi.pm 2.42
Socket.pm 1.6
Mime::Lite (Lite.pm,v 1.134 1999/04/17 04:59:03 eryq Exp)
----------------------------------------------
The test script:
$| = 1;
###### LIBS ##########
use strict;
use CGI qw/:standard :html3/;
use CGI::Carp qw(fatalsToBrowser); # carpout ====> # for Apache
use Apache::DBI();
use Apache qw(exit);
 
myRun();
Apache::exit;
 
 
 
##########
sub myRun {
 
 
  print header();
  print start_html(-title => 'Mime test');
  print '<h4>This one should work.</h4>';
 
  use lib 'c:\perl\lib\site\mime';
  use MIME::Lite;
  my ($OpStatus, $recip, $SMTPRetVal);
  $recip = '[EMAIL PROTECTED]';
  print '<br>TestMime: Starting test of Mime';
  my $SMTPhost = 'rcisd.com';
  print '<br>TestMime: Host = ' . $SMTPhost;
  my $messbod = 'Testing mime module';
  my $Subj = 'TestMime';
  my $msg;
  $msg = '';
  $msg = build MIME::Lite From => '[EMAIL PROTECTED]',
    To => $recip, Subject => $Subj,
    Type => 'TEXT', Data => $messbod;
    print "<br>TestMime: Recipient = $recip.";
  eval{
    $SMTPRetVal = $msg->send_by_smtp($SMTPhost, Timeout => 40);
  };
  if($@) {
    print "<br>TestMime: Status after mail via $SMTPhost was: <br>$@";
  }
  if($SMTPRetVal) {
  } else {
    print q(<br><font color='#FF0000'>TestMime: Send Failed for ) . $recip . '</font>';
  }
  undef $msg;
  print '<br>Done';
  print end_html();
  return;
}
----------------------------------------------
Apache startup.cgi:
use strict;
use Apache ();
use Apache::Registry;
use Apache::DBI();
use Carp();
use CGI qw(-compile :all);
 
 
#use lib map { "$ENV{PWD}/blib/$_" } qw(arch lib);
#use lib map { Apache->server_root_relative("blib/$_") } qw(arch lib);
1;
__END__
 

Reply via email to