Forum Moderators: phranque

Message Too Old, No Replies

Perl Sendmail in Apache-tomcat

socket failed (Unknown error)

         

udot

4:55 am on Sep 19, 2007 (gmt 0)

10+ Year Member



Hi,
I am using Perl5.6 on Windows XP..and an Apache-Tomcatserver to host my web page. Though I am able to send mails using Mail::Sendmail in perl, I am not able to do so using CGI from browser.

Here is the Perl script which sends mail successfully....


use Mail::Sendmail;

%mail = ( To => 'somebody@somewhere',
From => 'blah@blah',
Subject =>'sample subject',
Message => "sample message"
);

sendmail(%mail) or die("mail NOT sent \n\nERROR DETAILS: \n". $Mail::Sendmail::error);

print "Log says:\n", $Mail::Sendmail::log;

But when i am using this in my CGI script and open that cgi page from my browser, it gives an error..

Here is my CGI script which is almost same to previous one.


use CGI;
use Mail::Sendmail;

print "Content-Type: text/html\n\n";

print "<html> <head>\n";
print "<title>testmail</title>";
print "</head>\n";
print "<body>\n";

%mail = ( To => 'somebody@somewhere',
From => 'blah@blah',
Subject =>'sample subject',
Message => "sample message"
);

if(sendmail(%mail)) {print "<p>Success!";} else { print("mail NOT sent \n\nERROR DETAILS: \n". $Mail::Sendmail::error);}

print "<p>Log says:<p>\n". $Mail::Sendmail::log;
print "</body> </html>\n";


unfortunately i have never seen that "Success" :( :(
Here is the **latest** ouput in internet explorer i have seen...


mail NOT sent ERROR DETAILS: socket failed (Unknown error)
Log says:

Mail::Sendmail v. 0.79 - Tue Sep 18 15:00:45 2007 Date: Tue, 18 Sep 2007 15:00:45 +0530

...for mail server i am using Default SMTP virtual server in IIS...looking at the error type socket failed (Unknown error), I am at sea as to what after should I run! Is it Perl(nope ..i don think so!) or if is it socket error? (then what is the actual error? how can I fix an error which is termed as Unknown :( :( )
..
PLZZZZZZZZZ Help me out .. :( :( :(

phranque

7:07 am on Sep 19, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i would try using something like the Socket or IO::Socket perl packages to create a test socket directly in your cgi script instead of buried in the Mail::Sendmail package and see if you can get a better error message.
you might also try another mail package such as Mail::Sender to see if it works better on xp.

udot

9:13 am on Sep 19, 2007 (gmt 0)

10+ Year Member



phranque.. i could not get it.. are u trying to say i should connect the smtp port in the CGI script like adding these lines

$sock = IO::Socket::INET->new('{ip}:{smtp port usually 25}');
connect(Socket_Handle,$sock);

i havnt worked on IO::Socket modules before... so I dont have much idea about...

jdMorgan

12:54 pm on Sep 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Continues here: [webmasterworld.com...]