Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
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 to

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 to 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) generates an email through PHP

2) the MTA "understands" the fact I'm sending an email that "is arriving" from

3) the MTA picks up the correct SMTP username/password with which connect to the external smtp relay. ( that will be - 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.

share|improve this question

marked as duplicate by mailq, Scott Pack, EEAA, Ward, rnxrx Aug 25 '12 at 5:42

This question was marked as an exact duplicate of an existing question.

10 domains - 10 different relays of you'll use one for all? – Lazy Badger Oct 14 '11 at 16:27
One relay for all, with different username/password combination for each "From:" sender – peter.bishop Oct 18 '11 at 9:18

You have not indicated what MTA you are using, But that should be fairly simple to implement with both postfix and exim.

For postfix look at

For exim you need to write a lookup to pick up the correct auth details from a data source, e.g file.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.