Postfix: SMTP Relay based on alias (from address)

I guess you can achieve this by tuning the sender_dependent_default_transport_maps or sender_dependent_relayhost_maps Postfix parameters. For example:

# /etc/postfix/main.cf
sender_dependent_default_transport_maps = hash:/etc/postfix/sender_maps.cf
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sender_credentials.cf
smtp_sasl_tls_security_options = noanonymous
smtp_sender_dependent_authentication = yes
smtp_tls_security_level = may

# /etc/postfix/sender_maps.cf
[email protected] smtp:[smtp.xpto.com]:587
[email protected] smtp:[smtp.corpx.com]

# /etc/postfix/sender_credentials.cf
[email protected] xptouser:xptopassword
[email protected] corpxuser:corpxpassword

This example uses static hash tables. If your Postfix installation supports mysql_table(5), you can use MySQL queries instead.

I am unable to test this solution now. I hope it works.