Mail Script Issues on New VPS

griffeymania

New Member
Hi,

I have the following issue and am wondering if someone out there may have an idea what is going on. In a nutshell, I have a new VPS on which I have a Perl script that won't run from the browser but *will* run from the command line.

The script uses Mail::Sender, a common mail sending Perl module. I have a simple script set up to send me an email. This script works fine from the command line but times out from the browser. If I comment out the mail sending part of the code it works fine in the browser.

This script was copied directly from my other VPS. It works both on the command line and browser there. Somehow, I think the new VPS has permissions set up differently so that the httpd process owner can't execute the mail sending part of the code. I haven't been able to locate the appropriate error log that may hint at the reason. Here is the code:

>>>BEGIN CODE>>>
#!/usr/bin/perl
use Mail::Sender;
use CGI;
use strict;

my $txt_msg = "This message is in HTML format. Please switch to HTML view in your email program.";
my $html_msg = $txt_msg;
my $sender = new Mail::Sender();

my $from = "orders\@rmspraying.com";
my $to = "brady\@brandnewgraphics.com";
my $subject = "Order Submitted";
if (ref $sender->OpenMultipart({
smtp => 'mail.rmspraying.com',
from => "$from",
to => "$to",
subject => "$subject",
auth => 'LOGIN',
authid => '[my username here]',
authpwd => '[my password here]',
multipart => 'related'})) {
$sender->Part({ctype => 'multipart/alternative'});
$sender->Part({ctype => 'text/plain', disposition => 'NONE', msg => $txt_msg});
$sender->Part({ctype => 'text/html', disposition => 'NONE', msg => $html_msg});
$sender->EndPart("multipart/alternative");
$sender->Close() or die "Close failed! $Mail::Sender::Error\n";
} else {
die "Cannot send mail: $Mail::Sender::Error\n";
}

my $q = new CGI;

print $q->header('text/html');
print "Hello, World!\n";
>>>END CODE>>>

The mail server that it is connecting to is located on my other VPS. I don't think that part is the issue since I can run this from the command line. Any ideas would be greatly appreciated!

Thanks,
Brady
 
Hello Griffeymania and welcome to KH :D

I think the log file you want to take a look at will be the Apache error log and you should find it at /usr/local/apache/logs/error_log so take a look in there and hopefully that will give you something to look at.
 
Re:

Hi, Dan,

Thanks for the suggestion--I checked the Apache error log but it doesn't appear to be logging the error. I ended up running the script on the command line as user 'nobody' (the same user as httpd uses) and the program just hung (same behavior as from the browser).

There is a setting in WHM -> Tweak Settings to prevent the user 'nobody' from sending mail to remote users but this was unchecked. I even tried sending mail from a local user to the same account to no avail.

Anyone out there have an idea why 'nobody' would be unable to send mail?

Thanks,
Brady
 
Hi, khiltd,

The permissions are currently 755 nobody:nobody. The script just hangs as if it is trying to connect to the mail server but never times out.

Running it as root executes the script in less than a second.

Thanks,
Brady
 
Then some part of your script is probably dependent on some aspect of the shell environment its running in and needs to be debugged. I don't work in Perl, so I can't help you with that, but I'm sure whoever wrote it can.
 
Top