[imp] spamassassin/razor tie-in ...

Marc G. Fournier scrappy@hub.org
Sat, 27 Apr 2002 02:23:32 -0300 (ADT)


On Fri, 26 Apr 2002, Jan Schneider wrote:

> Zitat von "Marc G. Fournier" <scrappy@hub.org>:
>
> > Would it be as simple as:
> > +        $raw_msg = imap_fetchheader($imp['stream'], $index, FT_UID) .
> > "\n" . imap_body($imp['stream'], $index, FT_UID);
> > +        exec("echo $raw_msg | " . $conf['spam']['program'] . ' -a ' .
> > $spell_opt, $warnings);
>
> Oooooh, piping a spam message through exec(). Bad, bad, bad, bad idea! ;-)

This better?

*** message.php.orig    Thu Apr 25 15:49:29 2002
--- message.php Sat Apr 27 02:21:51 2002
***************
*** 344,349 ****
--- 344,362 ----
           break;
       }

+      if($conf['spam']['program']) {
+
+        $raw_msg = imap_fetchheader($imp['stream'], $index, FT_UID) . "\n" . imap_body($imp['stream'], $index, FT_UID);
+
+        $pipe = popen($conf['spam']['program'], 'w');
+        fwrite($pipe, $raw_msg);
+        pclose($pipe);
+
+        $notification->push(_("This message has been reported as spam."), 'horde.message');
+        break;
+
+      }
+
       /* Fetch the raw message contents (headers and first 10k of body). */
       $raw_msg = imap_fetchheader($imp['stream'], $index, FT_UID) . "\n" .
           substr(imap_body($imp['stream'], $index, FT_UID), 0, 10240);