Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

  1. how (if at all) the return code is used by postfix (what are the expected return codes and what effect do they have).
  2. 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.
  3. Can this command deffer accepting a mail (effectively tell postfix to try again later) - this could be answered by (1).
  4. Is the stdout / std error logged or otherwise used in any way?

Does anyone know where this information can be found?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

As usual, the postfix documentation is complete in describing its behaviour.

From local(8):

Mailbox delivery can be delegated to an external command specified with the mailbox_command_maps and mailbox_com- mand configuration parameters. The command executes with the privileges of the recipient user (exceptions: sec- ondary groups are not enabled; in case of delivery as root, the command executes with the privileges of default_privs).

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.

share|improve this answer
    
Ah I hadn't found that the manual page for local contains this. Thanks very much. –  couling Mar 14 '12 at 13:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.