Mail::Sender bad file descriptor (Apache for Win32 on win2k, ActiveState Perl 5.6, Win2k SMTP server) 
Author Message
 Mail::Sender bad file descriptor (Apache for Win32 on win2k, ActiveState Perl 5.6, Win2k SMTP server)

Hi.

The system I am using includes Apache for Win32 on win2k, ActiveState
Perl 5.6, and a Win2k SMTP server.

In the code shown below I am sending an e-mail containing the contents
of a form using the mail::sender module. If I send a simple text
string in the body e.g. "hellO" It sends without a problem, however as
soon as I introduce the form information it seems to hang until the
smtp server times out and then comes back with a 'bad file descriptor'
message.

I am new to perl and am unsure whether this is caused by my code, the
module, or the SMTP server.

            Any help would be greatly appreciated.

                   Rob Durant.

code follows:
#################################################

#!c:/perl/bin/Perl.exe

use CGI;
use strict;
use Mail::Sendmail;
use MIME::QuotedPrint;
use HTML::Entities;

print "content type: text/html\n\n<html>Mailout<br><br>";

my $q = new CGI;
my $mailString;

#split down URL
sub splitURL
{

  my %formdata;

  my $name_value;

  if($ENV{REQUEST_METHOD} eq 'POST')
  {
    my $query = "";
    read( STDIN, $query, $ENV{CONTENT_LENGTH}) == $ENV{CONTENT_LENGTH}
or return undef;

  }

  print "<table width=400 class=formHolder><tr><td>";


  {
    my( $name, $value ) = split /=/, $name_value;
    print "<table class=form width=100%><tr><td
width=50%>",$name,"</td><td width=50%>",$value,"</td></tr></table>";
    $value =~ tr/+/ /;  
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $mailString = "$mailString\n$name\t$value";
  }
  print "</td></tr></table>";

   print "<h3>The following details are being sent to
abc.org</h3><p>When the send is complete you will be redirected back
to the conference home page.</p>",$mailString;

Quote:
}

sub sendMail
{
  print "<h3>Preparing to send mail:</h3>";

  # setup mail object ready for sending
  my %mail = (
      To      => 'Rob_Durant <MASKED>',
      From    => 'Rob Durant <MASKED>',
      Subject => 'New online booking form details...',
      'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION",
  );

  #include this line!
  $mail{Smtp} = 'ansmtpserver.hgc';
  $mail{tz} = '+0000';
  $mail{mime} = 0;
  $mail{'X-custom'} = 'Content: text/html\n\n';
  $mailString = encode_qp($mailString) or print $!;
  $mail{'mESSaGE : '} = $mailString or print $!;

  # cheat on the date:
  $mail{Date} = Mail::Sendmail::time_to_date( time() - 86400 ),

  print "<p>Trying to send your mail...</p>";

  if (sendmail %mail)
  {
     print "<p>Mail sent OK.</p>";
  }
  else { print "<h3>Error sending mail: $Mail::Sendmail::error
($!)</h3>" }
  print "<p>\$Mail::Sendmail::log says:\n",
$Mail::Sendmail::log,"</p>";

Quote:
}

splitURL() or print "Unable to complete request (splitURL) $!";
sendMail() or print "Unable to complete request (sendmail) $!";

################################################################



Sat, 12 Mar 2005 20:51:46 GMT  
 Mail::Sender bad file descriptor (Apache for Win32 on win2k, ActiveState Perl 5.6, Win2k SMTP server)

Quote:

> Hi.

> The system I am using includes Apache for Win32 on win2k, ActiveState
> Perl 5.6, and a Win2k SMTP server.

> In the code shown below I am sending an e-mail containing the contents
> of a form using the mail::sender module. If I send a simple text
> string in the body e.g. "hellO" It sends without a problem, however as
> soon as I introduce the form information it seems to hang until the
> smtp server times out and then comes back with a 'bad file descriptor'
> message.

> I am new to perl and am unsure whether this is caused by my code, the
> module, or the SMTP server.

>             Any help would be greatly appreciated.

>                    Rob Durant.

> code follows:
> #################################################

> #!c:/perl/bin/Perl.exe

> use CGI;
[snip]


After pulling in the x-thousand lines of code that are CGI.pm, why in
the world do you go and try parsing the CGI protocol data yourself?

use CGI;
sub read_cgi_data {
   print "<table class=form width=100% cols=2>"
   for my $name (query()) { for my $value (query($name)) {
      print "<tr>";
      print "<td width=50%>", $name, "</td>";
      print "<td width=50%>", $value, "</td>";
      print "</tr>";
      $mailString .= $name . "\t" . $value . "\n";
   } }
   print "</table>";

Quote:
}

--
Announcement in the Zoo:
"Please don't scare the ostriches! Cement floor!"


Sun, 13 Mar 2005 09:51:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ActiveState 509, "Bad File Descriptor", perl -e

2. File::Copy WIn32 bad file descriptor

3. Bad file descriptor from Mail::Mailer

4. Unable to print - bad file descriptor

5. select() "Bad File Descriptor" problem

6. IPC::Open2 and bad file descriptor

7. Can't instantiate Net::SMTP on remote host --bad file descriptor

8. "bad file descriptor" error

9. Using open() for IPC -- can't fork due to bad file descriptor

10. select - Bad file descriptor

11. select() "Bad File Descriptor" problem

12. System call return value 256 - Bad file descriptor

 

 
Powered by phpBB® Forum Software