Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

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.

1 Answer 1

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

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
1  
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.