Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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:
Configuring php mail() per domain

I've many VirtualHosts on my Apache webserver with some different CMS (different services, different domain names, different administrators).
I would restrict php mail() function on every VirtualHost to send emails only from apriopriate/given email address (ie. VirtualHost from, from etc.). So when somebody uses mail() function, email should be automatically sent from given (by me) email address.
Emails should be sent via sendmail which is configured to handle emails from multiple domain names (not SMTP).
Is that possible? How?

share|improve this question

marked as duplicate by mailq, Iain, the-wabbit, Scott Pack, Shane Madden Dec 19 '11 at 17:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Look at example #3 in the manual:

mail('', 'the subject', 'the message', null,

Which will send the mail on behalf of

share|improve this answer
Yes, I know the 4th and 5th parameter of mail() function, but I want to restrict sending emails from different domain that the one set in VirtualHost, or automatically set the proper email FROM header. – daftu Dec 19 '11 at 8:11
Read the duplicate question and close yours. – mailq Dec 19 '11 at 8:13

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