Hey all, I have a little PHP script that is triggered by qmail when a message comes into a qmail mailbox... that works great, but qmail needs an 'exit code' to be returned to it, or else it will keep sending me the same message over and over (hate when that happens!).

My script is invoked as follows:

#!/usr/local/bin/php -q
<?php
 // ... script ...
?>

--so the question is, what's the right way to pass a status code back to qmail? qmail passes me the msg on stdin; do I have to fwrite the return code to stdout or something weird like that?

Here's the bit on qmail exit codes, FWIW-- qmail is just looking for a number:
http://www.ezmlm.org/faq-0.40/qmail-command.8.html

Thanks in advance for any help.

best,
Eric

    My (theoretical) understanding is that you can specify what exit code PHP returns on exit by specifying it in the call to exit(). Sorry, can't find an apropos example - can't seem to resolve www.ezmlm.org - but if you want PHP to return an exit code of 57, that would be exit(57);.

    Caveat: Your post reminded me of something in the changelog for PHP4.2.3:

    * Report the right exit code after a call to exit(). (Edin)

      Hey weedpacket! thanks for the quick help. And I can't believe you pulled that changelog reference out of the air, too ;-) I'll try it...

      best,
      Eric

        Write a Reply...