On 21.9.2013, at 20.32, Charles Cazabon charlesc-dovecot@pyropus.ca wrote:
The mail_filter plugin allows you to pass messages through an external script/command on the way into and out of the Maildir/mbox/etc mail store. With the recent/new version of the plugin, this seems to work correctly.
However, my mail-filter script (for filtering messages on the way from the mail store through the IMAP process to a remote client) needs some extra info from the IMAP mail process. I'm having difficulty figuring out how this can be accomplished.
Ideally, I'd like to pass another open file descriptor (opened in the IMAP process) to the script, but I'm not sure if this is possible. Opening the file in the IMAP main.c fails, presumably due to file descriptor limits, but I don't see where restrict_fd_limit() is called there.
imap process communicates with the mail_filter process via UNIX socket. It would be possible to pass a file descriptor, but it would need motifications to both the mail-filter/[io]stream-ext-filter.c and to src/util/script.c to use fd_send() and fd_recv().
Without modifications the only way to pass data is via the plugin { mail_filter } parameters, such as the %u expanding to username in the example. If you want some other parameters that don't exist in %variables (they get expanded immediately when the imap process starts), you need to modify for example mail-filter-plugin.c where it passes muser->args and muser->out_args to [io]_stream_create_ext_filter().