Hello there

I have a question about multiple MS records for each multiple domains.
The scenario:
I have Domain1 and Domain2
Domain1 has MX record pointing to 1.1.1.1 and Domain2 pointing to 2.2.2.2
I host both of them and I have a distributed environment behind a firewall NAT:
BOX1:MTA
BOX2: LDAP/DNS
BOX3:WEB.
The question is how does the MTA knows which IP address to send an email from each domain to the outside ?

Thanks