Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 09-24-2009, 01:25 PM   #1
LQ Newbie
Registered: Jun 2009
Location: Romania
Distribution: CentOS CLI-only kernel 2.6.18-194.32.1.el5
Posts: 22

Rep: Reputation: 2
PHP: How to change email sender per directory (apache vhost)


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.
Old 09-26-2009, 09:58 PM   #2
Registered: Dec 2004
Distribution: Slackware, Arch, FreeBSD
Posts: 202

Rep: Reputation: 34
The page for the php mail function looks pretty helpful:

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

$to = '';
$subject = 'the subject';
$message = 'hello';
$headers = 'From:' . "\r\n" .
'Reply-To:' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
Old 09-29-2009, 03:21 AM   #3
LQ Newbie
Registered: Jun 2009
Location: Romania
Distribution: CentOS CLI-only kernel 2.6.18-194.32.1.el5
Posts: 22

Original Poster
Rep: Reputation: 2
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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
apache directory change luciusl Linux - Server 1 03-02-2007 07:10 AM
How Do I Change The Default Directory For Apache? Tear Syden Linux - Newbie 4 03-21-2006 11:16 PM
Need program that verifies email sender before delivering. 360 Linux - Software 0 03-06-2006 01:41 PM
Mail from Apache being rejected - Cannot route to sender apache@localhost.localdomain jimwillsher Linux - Networking 2 01-19-2006 01:41 AM
Apache: Alias is working on ssl vhost but not on mass vhost jonavogt Linux - Software 0 06-07-2005 03:05 PM > Forums > Linux Forums > Linux - Server

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration