one way to do it is to use procmail to filter incoming mail and piping the ones you are interested into your python program which will take the rfc822 message on stdin. the email module (http://docs.python.org/lib/module-email.html) will let you parse these messages.
this is provided that your MX dns entry points to your machine and that you have the appropriate ports unlocked, of course.
this is provided that your MX dns entry points to your machine and that you have the appropriate ports unlocked, of course.