I am using postfix in my production server which will receive all the emails related to mydomain.com In this context, I want to forward only emails related to few users to different email addresses. By which I mean, lets say I am a super user(superuser@mydomain.com). I want to forward all my emails(all mails with to:superuser@mydomain.com) to my personal email id: superuser@gmail.com. So I think I would some programming logic is needed here. So I want to write a custom python script which should read the postfix email inbox and forward all new emails depending on the said criteria. Can I do this? I heard about .forward file in the postfix arena. Can I use that to achieve the same(by totally bypassing pythonic solution)?
Procmail is the solution for mail filtering. You can call python scripts from your .procmailrc if you need more scripting.
How do I read/retrieve emails received by local postfix, through python