Having failed to find an answer to this elsewhere, I am opening this question more widely.
I need to execute a bash shell command when a properly constructed email is received (I'm using GMail) using Python. I have previously used Python to send emails, but the only solution I have yet found is to use feedparser and Google Atom, which I don't like. I would suggest that a keyword could exist in either the subject or body of the email; security is not an issue (I don't think) as the consequence is benign.
The bash command to execute will actually call another scripts to send the latest jpg from my Python motion detection routine which runs independently.
procmail does this kind of thing trivally - checking the format of an incoming email and running a shell script that is.  There's no need to reinvent the wheel
I'm not entirely clear from your description how python fits in to what you want to do..
Hope this helps!
Execute shell command when receiving properly constructed email