I've been asked to provide a way of loading incoming e-mails, manipulate some part of the text and then forward it to the web server for the client to read. Basically, intercept the mail, put it through another process and once this process is finished - this is important - throw it at the web server, exactly as it was going to happen before my process intercepted.
Besides the actual e-mail file I also need to read information about the account from a MySQL db.
The mail server is Postfix/Dovecot and the Web server is Apache - running on CentOs. They could be running on the same server or not. I do not want to do the server's work and scan for viruses or do any authentication - all this should have already happened.
I have looked into some caching ideas, or even using NginX as an IMAP proxy but I think it's like trying to kill a fly with a shotgun. To make things worse I'm not actually a web person so I don't know all the Apache intricacies.
Does anyone have any ideas as to when is the right time to intercept this e-mail before it gets to the browser in a seamless way ?
Any help would be much appreciated.
Many Thanks