LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   PHP: How to change email sender per directory (apache vhost) (http://www.linuxquestions.org/questions/linux-server-73/php-how-to-change-email-sender-per-directory-apache-vhost-757538/)

ciuly 09-24-2009 12:25 PM

PHP: How to change email sender per directory (apache vhost)
 
Hi,

I'm trying to find a *working* solution for changing the email sender for the php mail function running as a module on apache 2.0.x on a per directory/virtualhost basis.
Not sure if it matters, but the server has and uses xmail 1.23+
Running on RH9, with most stuff installed from sources, not RPM.

bmarx 09-26-2009 08:58 PM

The page for the php mail function looks pretty helpful:

http://us.php.net/manual/en/function.mail.php

The code below will have to be fed the virtualhost name ($_SERVER['SERVER_NAME']) or the directory name ($_SERVER['PHP_SELF']) to decide what will go in the From field

<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

ciuly 09-29-2009 02:21 AM

sorry for not mentioning this, just figured it was obvious: I need something that can be applied without changing the sources. I have quite a few sites with different scripts and if I go about changing sources, upgrading will be a pain.

thanks.


All times are GMT -5. The time now is 09:07 AM.