Click here to get back home

Net::SMTP - "Bad File Number" error ?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Net::SMTP - "Bad File Number" error ? still just me 03-08-2008
Posted by still just me on March 8, 2008, 2:49 am
Please log in for more thread options
I'm using Net::SMTP to send mail from a perl program running on a web
server. Code is as follows:

my $relay="smtp.example.com";
my $smtp = Net::SMTP->new($relay);
die "Could not open connection: $!" if (! defined $smtp);

I'm familiar with the error you get when the SMTP server won't let you
in. It's usually "Could not open connection: Connection refused at
line... ". I run into that from time to time and the server people fix
what they messed up.

On this particular server (which used to work, but apparently they've
made changes), I'm now getting this error:

"Could not open connection:Bad file number at
/public_html/cgi-bin/submit.pl line 101"

What does "bad file number" mean?

Thanks,


Posted by Frank Seitz on March 8, 2008, 3:33 am
Please log in for more thread options
still just me wrote:
> I'm using Net::SMTP to send mail from a perl program running on a web
> server. Code is as follows:
>
> my $relay="smtp.example.com";
> my $smtp = Net::SMTP->new($relay);
> die "Could not open connection: $!" if (! defined $smtp);

I think $! is not meaningful here. See "perldoc perlvar"
for the definition of $!.

> What does "bad file number" mean?

It means, that a file handle was used that was not open.

Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

Posted by Joe Smith on March 9, 2008, 8:11 am
Please log in for more thread options
still just me wrote:
> I'm using Net::SMTP to send mail from a perl program running on a web
> server. Code is as follows:
>
> my $relay="smtp.example.com";
> my $smtp = Net::SMTP->new($relay);
> die "Could not open connection: $!" if (! defined $smtp);

The docs for Net::SMTP does not say that it sets $!, so don't rely on that.

Have you tried turning on debugging?

$smtp = Net::SMTP->new(
Host => 'smtp.example.com',
Hello => 'my.mail.domain'
Timeout => 30,
Debug => 1,
);

Posted by still just me on March 10, 2008, 3:57 pm
Please log in for more thread options

>still just me wrote:
>> I'm using Net::SMTP to send mail from a perl program running on a web
>> server. Code is as follows:
>>
>> my $relay="smtp.example.com";
>> my $smtp = Net::SMTP->new($relay);
>> die "Could not open connection: $!" if (! defined $smtp);
>
>The docs for Net::SMTP does not say that it sets $!, so don't rely on that.
>
>Have you tried turning on debugging?
>
> $smtp = Net::SMTP->new(
> Host => 'smtp.example.com',
> Hello => 'my.mail.domain'
> Timeout => 30,
> Debug => 1,
> );

Interesting on the $! issue... it seems to throw the right error when
the connection is refused. As you noted, perhaps the other message is
not reliable.

What should the debug mode above do for me? I don't seem to get any
additional information when I incorporate it.

Posted by still just me on March 10, 2008, 4:01 pm
Please log in for more thread options
On Mon, 10 Mar 2008 19:57:16 GMT, still just me


>Interesting on the $! issue... it seems to throw the right error when
>the connection is refused. As you noted, perhaps the other message is
>not reliable.
>
>What should the debug mode above do for me? I don't seem to get any
>additional information when I incorporate it.

Whoops... ignore that question about the debug mode. Operator error
prevented me from seeing that it was dumping a message. I'll continue
studying the original issue.

Thanks,


Similar ThreadsPosted
Net::SMTP module error September 28, 2006, 8:29 am
Error using SMTP object. November 30, 2007, 7:57 pm
Mail::SendEasy smtp error, July 21, 2005, 1:56 pm
Net::SMTP error: Can't locate Mail/Sender.pm in @INC May 19, 2005, 10:33 am
perlcc error - 'Can't unlink error file...' April 7, 2006, 10:13 am
Problem directing BCP Error to Error file January 16, 2008, 6:20 am
FAQ 5.3: How do I count the number of lines in a file? December 4, 2004, 6:03 am
FAQ 5.32: How do I close a file descriptor by number? December 16, 2004, 12:03 pm
FAQ 5.3: How do I count the number of lines in a file? January 6, 2005, 12:03 am
FAQ 5.20 I still don't get locking. I just want to increment the number in the file. How can I do this? January 20, 2005, 6:03 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap