EvR has asked for the wisdom of the Perl Monks concerning the following question:

A similar question was posted in January, but I am having a slightly different problem with Mime::Lite. Specifically, I have a CGI script that sends email. in the script, I use very standard code like this:
use strict; use MIME::Lite; # vars defined here for use in the next statement my $msg = MIME::Lite->new ( From => $from_address, To => $to_address, Subject => $subject, Type => $msg_type, Data => $body_text, ); MIME::Lite->send( $method, $host, Timeout=>$timeout ); $msg->send;
I have this in a CGI script. When I run the script on one web server (IIS v5 on Win2K -- sorry, not my choice, but that is what I have), it works perfectly. Sends the email just fine. On another server (also IIS v5 on Win2K), with use CGI::Carp qw( fatalsToBrowser ); I get the following error in the browser:
Failed to connect to mail server: Unknown error

Now here is the odd part... I can run the exact same script from the command prompt (on the same server) as follows:

perl scriptname.pl action=send_msg email=email_address (Simulating a web page passing arguments)

The script works perfectly. It seems odd that the script runs fine on one server, fine from the command prompt on the second, but does not run correctly when run on that server from a web page.

I really do not know what to check next. I appears to be some interaction of the perl script -- specifically the send operation in Mime::Lite -- with the specific installation of IIS. I have looked at various IIS config issues, but nothing seems to explain the problem.

Any insight would be greatly appreciated.

Thanks,

Rick

Replies are listed 'Best First'.
Re: Mime::Lite Connection Error
by rpanman (Scribe) on Jul 31, 2007 at 07:47 UTC
    It might be worth using the debug option:
    MIME::Lite->send( $method, $host, Timeout=>$timeout, Debug=>1 );
    This will print any errors to STDERR. Since I'm not sure where this will go on a web server so it's probably best to redirect STDERR to a file in this case. You can find out more about this here: How do I redirect STDOUT, STDIN, or STDERR to a FILE?
Re: Mime::Lite Connection Error
by Anonymous Monk on Jul 31, 2007 at 09:22 UTC