Postfix configuration: different outgoing hosts based on sender
I've got a problem that's driving me mad.
Basically, I run 10 virtualhosts in a CentOS distribution.
From now on, I'll call these virtualhost domains www.example1.com to www.example10.com
In the meanwhile, I've bought an external service, a mailserver, that will hold all the emails "related" to these domains. From now on I'll call these emails firstname.lastname@example.org to email@example.com. These email addresses are enabled to be used as "users" for the smtp relaying of emails through the mail server.
Obviously, all the MX records of these 10 domains have been configured to pinpoint to the correct external mailserver, so emails sent TO these addresses work as expected.
The problem is due to the fact that these 10 domains generate emails through PHP scripts. So, I need to configure my CentOS distribution to handle OUTGOING ( this is enough, I don't need the server to handle incoming emails as said before ) emails generated through PHP.
I would like to achieve a configuration like this:
1) www.example1.com generates an email through PHP 2) the MTA "understands" the fact I'm sending an email that "is arriving" from www.example1.com 3) the MTA picks up the correct SMTP username/password with which connect to the external smtp relay. ( that will be firstname.lastname@example.org - password-of-domain1 ) 4) the MTA connects to the external SMTP with the credentials found above, and dispatches the email
I would like to use this external SMTP relay for outgoing emails for a matter of consistency of the system. I would like to let the web server do his job, and the mail server the other job.
Any ideas or hints to reach this type of configuration? Since now I've tried configuring sendmail and postfix to achieve this, but I was unlucky.
P.S: I'm using GoDaddy as external email server.