Call PHP script in Postfix
I've used the following guide
I've tried adding a rule to the aliases file as detailed here
Why? Scales better, you can move to different config/mailserver/cluster with NO code changes (just imap connection params, if even that), plus you have better control over incoming and possibly outgoing messages that way, and such standardized code is then available for future use in different conditions.
Basically, I created forward in my database which forwards an email address to a local user account, then setup the aliases file to point the local account to the PHP script, works perfectly.
To answer you original question, I got mine to work by first adding an alias from the virtual domain to a local user:
Hope that makes sense, let me know otherwise.
edit: Haha, should remember to refresh before replying.
edit2: Heh, and now I realize you figured it out from a reply I had given someone else here. I had forgotten about that. Good times.