Spam Assassin giving invalid output
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>开发者_JS百科;
<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
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);
}
精彩评论