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 example.com from admin@example.com, foobar.com from admin@foobar.com 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?

link|improve this question
feedback

closed as exact duplicate by mailq, Iain, syneticon-dj, Scott Pack, Shane Madden Dec 19 '11 at 17:07

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

1 Answer

Look at example #3 in the manual: http://www.php.net/manual/en/function.mail.php

<?php
mail('nobody@example.com', 'the subject', 'the message', null,
   '-fwebmaster@example.com');
?>

Which will send the mail on behalf of webmaster@example.com

link|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
1  
Read the duplicate question and close yours. – mailq Dec 19 '11 at 8:13
feedback

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