So ActiveMailer has the ability to receive mail using a 'runner' to which you pass raw email (or rather, postfix, sendmail etc pass raw mail). The message is decoded and turned into a TMail object that is then passed to a 'receive' method on your ActiveMailer::Base subclass. I wanted my app to receive all emails sent to addresses that match a certain regular expression. The explanation on the rails wiki uses a regular expression and got me some of the way but it didn't mention the final step for getting this running on the OS X Server postfix installation. You need to add:
virtual_alias_maps = regexp:/etc/postfix/virtual
to /etc/postfix/main.cf. Just add it at the end. Here are my full notes for configuring postfix for receiving mail with rails:
--- In /etc/postfix/aliases add (all on one line):
my-app: "|/path/to/app/script/runner
-e production 'MyMailer.receive(STDIN.read)'"
--- In /etc/postfix/main.cf add to the end:
virtual_alias_maps = regexp:/etc/postfix/virtual
--- In /etc/postfix/virtual add:
/^.*@mydomain.com$/ my-app