OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Custom pipe script failure code

From: Alan Fullmer (lists-alanxnote.com)
Date: Tue Oct 02 2007 - 12:54:58 CDT


Hello,

I have a quick question regarding the pipe function in Postfix and the
use of PHP as a mail sorter/parser. I've looked around and see many
people have used PHP as a quick and dirty solution for putting mail data
into a database.

I am taking all incoming mail, parsing out headers and putting the mail
into a MySQL database. The problem I have is, if the script cannot
connect to the database, the script fails. What I want is to have this
message return back into the normal mail queue with a temporary failure
or something so it can retry at a later time without disappearing into
never never land. The reason for this, is if there is a connection
failure, or the database stops for some reason, I don't want these
messages to be lost due to a script failure.

Here is my pipe command:
spamfilter unix - n n - - pipe
  flags=DRq user=spamfilter argv=/scripts/spamfilter.sh -f ${sender} --
${recipient}

Here is my spamfilter.sh command:
#!/bin/bash
/usr/bin/spamc -f -u "$4" | /scripts/parsemessage.php "$4"
exit $?

So is there a way to exit(); with some sort of code to put that message
back into the queue? I have read that I need to exit(75); but that does
not work. If anyone could help, that would be more than fantastic.

Thanks,
Alan