Jump to content

PHP page and shell_exec() issue


ainoy31

Recommended Posts

I  have setup a page with a hyperlink where my ops people can go and test to see if the outgoing email they created is considered a spam or not.  After clicking on the link, the email content is sent to the following mailbox /var/spool/mail/spam which is working as defined.  I am using the Razor_Agent software to check for spam material on the emails.  So, I can now go to shell into the server and use this command to check the email sent in the spam mailbox.

 

razor-check /var/spool/mail/spamuser

 

This is working fine.  My problem is that when I try to auto the whole process, the email is sent but the razor-check does not get executed.  When I do a exec('whoami'), I get 'nobody'.  So, I try to edit my etc/sudoers file and add nobody ALL= (ALL) NOPASSWD:ALL with the hope of giving the permission to execute this linux command but no luck.  Here is my code:

 

$filename = $_GET['file'];

$template = '/var/projects/devv/xxx'.$filename;

$body=@file_get_contents($template);

$to_email = 'spamuser@localhost';
$from_email 	= '[email protected]';
$content ="text/html; charset=iso-8859-1";
$subject="Receipt No Signature";

$verify=mail($to_email, $subject, $body, sprintf("From: %s\r\nContent-Type: %s\r\n", $from_email, $content));
if(!$verify)
{
$status_message = "Test spam email failed.";
}
else
{
$status_message = "Test spam email passed.";
exec("razor-check /var/spool/mail/spamuser");
}

echo $status_message;

 

I have tried changing to root via exec("sudo bash razor-check /var/spool/mail/spamuser") and no luck.

 

Any suggestion is appreciated.  Thanks.

 

AM

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/167329-php-page-and-shell_exec-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.