On Wed, 2006-11-29 at 18:59 +0100, Leonardo Lanzi wrote:
parsing the mailing list archive, it seems that the lmtp-server will not be developed soon, so I'm looking for someone that could help me in writing one, even if not the best one. That's why:
Well.. Dovecot's deliver is what you should be looking to do this. Unfortunately its code is quite kludgy. For Dovecot v2.0 I'm doing larger changes which makes it much cleaner, but for now it's ugly..
Settings are read from environment variables. So in deliver there's now code which parses dovecot.conf itself and puts pretty much everything in it into environment variables. You'll need to do this or just set the environment variables manually somehow.
Do you need to parse the message in any way? If not and you just want to save it, then it's easier. You can use the mailbox_save_*() functions in src/lib-storage/mail-storage.h to do it. Deliver however wants to use the headers of the mails so it create an in-memory mbox formatted mailbox of the incoming message, which is rather ugly.
There's also src/plugins/convert/ which contains convert-tool binary. Its code is simpler than deliver's, and it might be easier to understand.
For seeing how mailbox_save_*() functions work, you can check how mailbox_copy() is implemented in src/lib-storage/mail-copy.c.
One reason why I don't really like implementing LMTP is because it doesn't work well with multiple UIDs. You've only 3 choices:
Run everything under a single UID
Run LMTP delivery code as root which is temporarily setuid to the user (security hole gives root access)
Fork a new process to handle each delivery (couldn't you just use deliver binary then?)