0

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?

Dawid Moś
  • 225
  • 1
  • 8

1 Answers1

3

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

mailq
  • 16,882
  • 2
  • 36
  • 66
  • 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. – Dawid Moś Dec 19 '11 at 08:11
  • 1
    Read the duplicate question and close yours. – mailq Dec 19 '11 at 08:13