I am trying to write simple php script to extract details (sender's email address, Subject name and content) from received email and store details in mongodb database.
Thanks in advance.
The easiest way would be to name your PHP (CLI) script in Postfix's configuration entry mailbox_command
. It is suggested in this post: Postfix - How to process incoming emails? and documented here: Postfix documentation.