I am writing a web application that should receive email messages to users' internal email addresses, allow administrators to approve them, and then forward them to the appropriate external user mailbox.
I installed and configured a postfix for the message receiving task. It uses virtual email addresses and my existing database where user email addresses are stored. The local email repository is maildir and I use postfix virtual MDA.
Basically, I would like to execute a script every time a new message is received, and for which the user (the message identifier maildir will also be very useful). Then I could read the message from python code (python had a module for maildir mailboxes) and paste it into the database. I can come up with three ways to do this:
- iterate user mail and check if there are new messages, but this will be ineffective for a large number of users.
- use dbmail and then check if there are new messages in the database (it would be faster, but I would have to configure everything from scratch). In addition, existing user data tables cannot be used.
- write a wrapper around maildrop / virtual to save the message in db and in maildir, but I need a way to check if the received message was successfully and successfully saved by MDA real .
Any suggestions appreciated!
source
share