How do I configure postfix to deliver mail for specified domains to another host, and deliver the rest using MX records

Instructions work for Ubuntu, you may need to adjust for other distros.

Add the following to /etc/postfix/main.cf:

relay_domains = domain1.com, domain2.com
transport_maps = hash:/etc/postfix/transport
relay_recipient_maps = hash:/etc/postfix/relay_recipients
relay_transport = relay

Create the file /etc/postfix/transport:

domain1.com  smtp:[mail.example.com]
domain2.com  smtp:[mail.example.com]

Create the file /etc/postfix/relay_recipients:

@domain1.com x
@domain2.com x

Run these commands:

$ sudo postmap /etc/postfix/transport
$ sudo postmap /etc/postfix/relay_recipients
$ sudo /etc/init.d/postfix reload