To use registered mail handlers with
qMail Mail Transfer Agent (MTA), you should write additional code that manages collaboration between handlers and the MTA.
The code should do the following:
Create handlers queue
When handling a message, the code should read registered handler names from
before-remote directories. For info on logical structure of handlers, refer to the Logical Structure of Handlers section of the API reference. The obtained names should be sorted, and the handlers called in a specified order.
Invoke handlers and manage handlers queue
The code that invokes handlers should be either patched into
qMail or installed as wrappers around
When calling a handler, the code should read from the handler's standard output. As soon as the handler sends
PASS, the next handler should be called receiving standard output of the previous handler on its standard input. There is no need to continue reading the standard output of the previous handler after this point.
The code should appropriately handle other resolutions issued by the handler on the standard error stream and translate them to
qMail exit codes. It should also monitor handlers for termination due to signals.
Put the last handler into qmail-queue
The output of the last handler should be piped into the actual
qmail-local, the output should be saved into a temporary file because
qmail-local requires standard input that can be searched through.
For info on mail handlers, refer to the Plesk Internal API and Mail Handlers (from API Reference) sections.