Ok,

     Here goes....

     1) I can from my server ping the mail server.
     2) I can from the Windows command line, telnet to port 25 (SMTP) of the
mail server. It works.
     3) Using a packet sniffer I see #2 happening.
     4) Using a packet sniffer I see nothing happening network wise from my
script.

PERL Example:

use strict;
use Net::SMTP;

    my $smtp = Net::SMTP->new($mailServer); # connect to an SMTP server
    $smtp->mail($senderEmail);           # use the sender's address here
    $smtp->to($recipientEmail);          # recipient's address
    $smtp->data(); # Start the mail

 # Send the header.
    $smtp->datasend("To: $recipientEmail\n");
    $smtp->datasend("From: $senderEmail\n");
    $smtp->datasend("Subject: $subject\n");

    $smtp->datasend("\n");               # Send the body.
    $smtp->datasend("$message\n");

    $smtp->dataend();                        # Finish sending the mail
    $smtp->quit;                             # Close the SMTP connection -ab


Output in logs


2006-10-05 00:17:29 StandardContext[]cgi: findCGI: path=/RFI.cgi, C:\Program
Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF/cgi

2006-10-05 00:17:29 StandardContext[]cgi: findCGI: currentLoc=C:\Program
Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\cgi

2006-10-05 00:17:29 StandardContext[]cgi: findCGI: currentLoc=C:\Program
Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\cgi

2006-10-05 00:17:29 StandardContext[]cgi: findCGI: FOUND cgi at C:\Program
Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\cgi\RFI.cgi

2006-10-05 00:17:29 StandardContext[]cgi: findCGI calc: name=RFI.cgi,
path=C:\Program Files\Apache Software Foundation\Tomcat
5.0\webapps\ROOT\WEB-INF\cgi\RFI.cgi, scriptname=/cgi-bin\RFI.cgi,
cginame=\RFI.cgi

2006-10-05 00:17:29 StandardContext[]cgi:
runCGI(envp=[{HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1,
HTTP_ACCEPT_ENCODING=gzip,deflate, REQUEST_METHOD=POST, AUTH_TYPE=,
HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5, SERVER_NAME=205.16.7.98,
SERVER_SOFTWARE=TOMCAT, HTTP_CONTENT_TYPE=application/x-www-form-urlencoded,
HTTP_REFERER=http://205.16.7.98/RFI/RFI.html, HTTP_KEEP_ALIVE=300,
HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7, HTTP_HOST=205.16.7.98,
GATEWAY_INTERFACE=CGI/1.1, X_TOMCAT_SCRIPT_PATH=C:\Program Files\Apache
Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\cgi\RFI.cgi,
REMOTE_ADDR=205.16.7.101, SERVER_PROTOCOL=HTTP/1.1,
HTTP_CACHE_CONTROL=max-age=0, PATH_INFO=, REMOTE_HOST=205.16.7.101,
QUERY_STRING=, HTTP_CONNECTION=keep-alive, SERVER_PORT=80,
CONTENT_TYPE=application/x-www-form-urlencoded, CONTENT_LENGTH=370,
HTTP_CONTENT_LENGTH=370,
HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5,
SCRIPT_NAME=/cgi-bin\RFI.cgi, REMOTE_USER=, REMOTE_IDENT=}],
command=C:\Program Files\Apache Software Foundation\Tomcat
5.0\webapps\ROOT\WEB-INF\cgi\RFI.cgi)

2006-10-05 00:17:29 StandardContext[]cgi: runCGI (stderr):Can't call method
"mail" on an undefined value at C:\Program Files\Apache Software
Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\cgi\RFI.cgi line 125.
2006-10-05 00:17:29 StandardContext[]cgi: runCGI: 1 lines received on stderr

It finds the CGI, begins to run the CGI, and when it gets to the

         $smtp->mail($senderEmail);           # use the sender's address
here

line it halts.

According to some PERL sources I have looked up, it will return that error
(Cant' call method "mail"...) when it fails to connect to the mail server.
For the server names I have tried the full server name, full name including
domain, and the IP address. I have stopped short of using semaphore flags
and morse code. :P

I can't even see the network ATTEMPTING a connection using a packetsniffer.
So it leaves me two options.

1) Tomcat is not allowing something.
2) ActivePerl is messed up in the head.

So I tried it from the command line.

I took that section of code, and ran it from the command line and it worked.

So ActivePerl is not messed up in the head. Is Tomcat running the script in
some sort of container that restricts what it can connect to?

I hope this helps.

Thank you in adavance.

V/R

Warren Halstead


Christopher Schultz-2 wrote:
> 
> Warren,
> 
>>> I am running Tomcat 5 with CGI enabled. I am attempting to use 
>>> Net::SMTP to send e-mail, and it works fine from the command line, but
>>> not running as a CGI script.
> 
> Can you describe the failure in any more detail?
> 
>>> I do not have that option, and so I must ask if there is some 
>>> security function in Tomcat or a workaround, that allows perl CGI 
>>> scripts to make a socket connection to port 25 of another server. 
> 
> It's possible, but let's find out what's going on before we start
> barking up the wrong tree.
> 
> Do you get an exception? Anything in your log files? Are you sure that
> your perl script is actually being invoked? If so, is there any error
> from the Perl interpreter? If so, what?
> 
> -chris
> 
> 
>  
> 

-- 
View this message in context: 
http://www.nabble.com/Re%3A-CGI-vs-SMTP-vs-Tomcat-tf2460372.html#a6866883
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to