I'd like to create a custom program for handling incoming mail from postfix. I'd like to hook this into postfix by making it the mailbox_command. The manual indicates that there are a number of environment variables which are set when this command is invoked, however it doesn't say much else and doesn't include any particular requirements of this command.
Specifically I'd like to know:
- how (if at all) the return code is used by postfix (what are the expected return codes and what effect do they have).
- The mail itself appears to be handed to the command by passing it into the stdin. Is this a pipe or a temp file or is this not defined? The difference this makes is that a temp file can be memory mapped where as a pipe needs to be read byte by byte.
- Can this command deffer accepting a mail (effectively tell postfix to try again later) - this could be answered by (1).
- Is the stdout / std error logged or otherwise used in any way?
Does anyone know where this information can be found?
As usual, the postfix documentation is complete in describing its behaviour.
From local(8):
If mailbox_command is set, local(8) behaves as it does under the next section, EXTERNAL COMMAND DELIVERY.
A mailbox_command is, obviously, an external command.
BTW the manual page you link to contains examples referring to, for one, procmail(1). This should provide a big hint on how mail is delivered to the command.