0

I want to use Spam-Assassin for scoring mails for spam before sending them to the users. I'm using PHP for executing it as a process using the exec.

exec("/usr/bin/spamc -R < {$fname}",$score,$rr);

The problem is that the result being returned is always 0/0. I took the PHP code from PHP Classes website. The demo message being used is below

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>free free</title>
<meta content="false" http-equiv="imagetoolbar">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body>
viagra test test free free
</center></body></html>

Please suggest what could be the problem

skaffman
  • 398,947
  • 96
  • 818
  • 769
Sam
  • 830
  • 2
  • 11
  • 22
  • Are you using a full filepath for $fname? – Mark Baker Jun 26 '10 at 10:52
  • yes.. `$fname= tempnam("/tmp","sa");` – Sam Jun 28 '10 at 04:28
  • If i use the same script on the other sites of mine, its working fine. This should be a Spam Assassin configuration issue. Anyone could suggest what is the necessary configuration to be done from scratch? – Sam Jun 28 '10 at 07:44

1 Answers1

0

Try changing the way you pipe in your email content using proc_open instead of exec:

$email_content = "Put your email content here."

$descriptorspec = array(
    0 => array("pipe", "r"),  // stdin read by child
    1 => array("pipe", "w"),  // stdout written to by child
    2 => array("file", "/tmp/spamd-error-output.txt", "a") // stderr
);

$process = proc_open("/usr/bin/spamc -R", $descriptorspec, $pipes);

if (is_resource($process)) {
    fwrite($pipes[0], $email_content);
    fclose($pipes[0]);
    $full_output = fgets($pipes[1], 1024);
}
JoshMock
  • 1,291
  • 1
  • 9
  • 21