You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Derek Harding <de...@innovyx.com> on 2007/03/02 21:40:47 UTC

Re: Message is Piped to a PHP script. CPANEL glitch preventing SA from Scanning before feeding to script.

On Fri, 2007-03-02 at 13:08 -0500, Don Ireland wrote:
> Is there a way to have my PHP Script feed a message to SA to be 
> scanned?  I can save the message as a text file if that'll help.



#!/usr/bin/php -q
<?
open(TMP, ">/tmp/sa.$$") || die("Error opening temp file: /tmp/sa.$$");
print TMP $mess . "\r\n";
close(TMP);

my $score = qx!/usr/bin/spamc -c </tmp/sa.$$!;
chomp($score);
if ($? >> 8 == 1)
  echo "It's spam.\n";

unlink("/tmp/sa.$$");
?>

Derek



Re: Message is Piped to a PHP script. CPANEL glitch preventing SA from Scanning before feeding to script.

Posted by Derek Harding <de...@innovyx.com>.
On Fri, 2007-03-02 at 12:40 -0800, Derek Harding wrote:
> On Fri, 2007-03-02 at 13:08 -0500, Don Ireland wrote:
> > Is there a way to have my PHP Script feed a message to SA to be 
> > scanned?  I can save the message as a text file if that'll help.
> 
> 
> 
> #!/usr/bin/php -q
> <?
> open(TMP, ">/tmp/sa.$$") || die("Error opening temp file: /tmp/sa.$$");
> print TMP $mess . "\r\n";
> close(TMP);
> 
> my $score = qx!/usr/bin/spamc -c </tmp/sa.$$!;
> chomp($score);
> if ($? >> 8 == 1)
>   echo "It's spam.\n";
> 
> unlink("/tmp/sa.$$");
> ?>

And guess who wrote perl instead of php? Yep, idiot here. Principle is
the same, codes a fraction different:

#!/usr/bin/php -q
<?
$fname = tempnam("/tmp", "sa");
file_put_contents($fname, $message);

exec("/usr/bin/spamc -c <$fname", $score, $res);

if ($res == 1)
  echo "It's spam.\n";

unlink($fname);
?>