tiredcoder has asked for the wisdom of the Perl Monks concerning the following question:
I'm having a strange problem with the following simple SMTP script. I am running it on my Win2000 workstation and it is trying to send mail through our Solaris server, which does have SMTP enabled for anonymous access.
The debug statements I get back are:use strict; use Net::SMTP; my $SMTP_SERVER = "xxx.x.xx.xxx"; my $EMAIL_DOMAIN = "xxx-xx.xxxx.com"; my $mailFrom = "myname\@domain.com"; my $subject = "Test SMTP Message"; my $msg ="This is a test message."; my $mailaddr = $ENV{USER} . "\@" . $EMAIL_DOMAIN; my $smtp = Net::SMTP->new($SMTP_SERVER, Debug => 1); print STDERR "Couldn't connect to smtp server: $!\n" unless $smtp; $smtp->mail($ENV{USER}."\@".$EMAIL_DOMAIN); $smtp->to('me@domain.com'); $smtp->data("\n"); $smtp->datasend("From: $mailFrom\n"); $smtp->datasend("To: me\@domain.com\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend($msg); $smtp->dataend(); $smtp->quit;
My research into the 'bad file descriptor' message suggests that I'm getting it because $! has no value since I've already lost the connection to the server. I've talked to our Solaris administrator (since I don't know Unix) and he can't find anything in the SMTP log that even shows I made a connection or encountered any errors on that side. He looked at the data returned by my script and agrees that it does look like I am connecting to the server, then being disconnected for some unknown reason. He tried sending an POP3 email message from my workstation using Outlook and relaying through the Solaris server and it was successful (with no authentication used). We are also able to use telnet on my workstation to send anNet::SMTP: Net::SMTP(2.16) Net::SMTP: Net::Cmd(2.19) Net::SMTP: Exporter(5.562) Net::SMTP: IO::Socket::INET(1.25) Net::SMTP: IO::Socket(1.26) Net::SMTP: IO::Handle(1.21) Net::SMTP=GLOB(0x1a72800)<<< 220 ESMTP xxx-xx.xxxx.com Sendmail 8.8. +8+Sun/SMI-S VR4 ready at Fri, 2 Apr 2004 13:12:58 -0500 (EST) Net::SMTP=GLOB(0x1a72800)>>> EHLO MY PC NAME Net::SMTP=GLOB(0x1a72800)<<< 250- xxx-xx.xxxx.com Hello xx.xx.xx.xxx, + pleased to meet you<br> Net::SMTP=GLOB(0x1a72800)<<< 250-EXPN Net::SMTP=GLOB(0x1a72800)<<< 250-VERB Net::SMTP=GLOB(0x1a72800)<<< 250-8BITMIME Net::SMTP=GLOB(0x1a72800)<<< 250-SIZE Net::SMTP=GLOB(0x1a72800)<<< 250-ONEX Net::SMTP=GLOB(0x1a72800)<<< 250-ETRN Net::SMTP=GLOB(0x1a72800)<<< 250-XUSR Net::SMTP=GLOB(0x1a72800)<<< 250 HELP Couldn't connect to smtp server: Bad file descriptor
I have tried every variation I can think of in the $smtp->mail(' ') line, since that's the first line sent to the mail server after the connection is established and I thought the problem might lie there. I have also tried adding the Helo and port parameters to the Net::SMTP->new line. I have tried specifying the smtp server name rather than the IP address. No matter what variations I try for the different values and addresses needed (and I've been working on this for 2 days now), I still get the same exact return code.
Does anyone have any suggestions as to what is going on or how I can get some better feedback from the Solaris server?
Thanks,
tiredcoder (really tired)
Edited by BazB fixed formatting, added code and readmore tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SMTP Connection Problem
by Thelonius (Priest) on Apr 02, 2004 at 19:55 UTC | |
|
Re: SMTP Connection Problem
by iburrell (Chaplain) on Apr 02, 2004 at 21:38 UTC | |
by tiredcoder (Initiate) on Apr 05, 2004 at 12:18 UTC | |
|
Re: SMTP Connection Problem
by nimdokk (Vicar) on Apr 02, 2004 at 23:44 UTC | |
by tiredcoder (Initiate) on Apr 05, 2004 at 12:34 UTC | |
|
Re: SMTP Connection Problem
by tachyon (Chancellor) on Apr 03, 2004 at 01:27 UTC |