Edit /kolab/etc/kolab/templates/master.cf.template
Locate the definition for the kolabmailboxfilter, and have it call your script instead of kolabmailboxfilter. Do this by copying the first line of the definition, commenting the original, and modifying the copy.
Eg:
#kolabmailboxfilter unix - n n - - pipe user=kolab-n flags=n argv=/kolab/bin/php
kolabmailboxfilter unix - n n - - pipe user=kolab-n flags=n argv=/kolab/extra/tnefpipe
/kolab/bin/php
The first (commented) line is a single line, even if it has wrapped in this document, and/or in your editor
Note: The primary change is argv=/kolab/bin/php has been changed to argv=/kolab/extra/tnefpipe, and /kolab/bin/php is now the first line of the following command.
Note: The rest of the comand is left untouched. So the entire definition for the kolabmailboxfilter becomes:
#kolabmailboxfilter unix - n n - - pipe user=kolab-n flags=n argv=/kolab/bin/php
kolabmailboxfilter unix - n n - - pipe user=kolab-n flags=n argv=/kolab/extra/tnefpipe
/kolab/bin/php
-c /kolab/etc/apache/php.ini
-f /kolab/etc/resmgr/kolabmailboxfilter.php
--
-h @@@fqdnhostname@@@
-s ${sender}
-r ${recipient}
-c ${client_address}
The tnefpipe script simply pipes its input through tnefclean -f (running as a filter), and pipes the output into whatever command it finds on the command line (which is basically whatever kolabmailboxfilter was doing before).