LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 09-24-2009, 12:25 PM   #1
ciuly
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)


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

Rep: Reputation: 34
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);
?>
 
Old 09-29-2009, 02:21 AM   #3
ciuly
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.

thanks.
 
  


Reply


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 06:10 AM
How Do I Change The Default Directory For Apache? Tear Syden Linux - Newbie 4 03-21-2006 10:16 PM
Need program that verifies email sender before delivering. 360 Linux - Software 0 03-06-2006 12:41 PM
Mail from Apache being rejected - Cannot route to sender apache@localhost.localdomain jimwillsher Linux - Networking 2 01-19-2006 12:41 AM
Apache: Alias is working on ssl vhost but not on mass vhost jonavogt Linux - Software 0 06-07-2005 02:05 PM


All times are GMT -5. The time now is 08:33 PM.

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