Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So here's my issue...I have two sites hosted on one machine using apache's virtual hosts. I want to send emails from the two different sites ( and using the appropriate email addresses. I currently have this value in php.ini:

sendmail_path = /usr/sbin/sendmail -t -i

But when I try sending an email from a script on it obviously is delivered with a From: header. Apache doesn't allow you to set a rule like this from within the <VirtualHost> directive:

php_admin_value sendmail_path "/usr/sbin/sendmail -t -i"

So what's the best way to accomplish this? I've tried setting php_admin_value mail.force_extra_parameters "" from within the's <VirtualHost> directive but all emails are still coming from Any ideas?

share|improve this question
Plase see:… – jeffatrackaid Dec 7 '11 at 17:12
I saw that, but editing every mail() call wasn't a viable option for me – Jeff Dec 8 '11 at 0:55
up vote 2 down vote accepted

Although you're not allowed to set the sendmail_path from within the <VirtualHost> directive, you can set it within the <Directory> directive. So I simply have something that looks like this:

<VirtualHost *:80>
    Standard stuff goes here

    <Directory /dir/to/your/web/root>
        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i"


I'm not sure if it's the most proper or elegant way to accomplish this, but it definitely worked. Sorry it took so long to respond, I don't go on SF that frequently and forgot about this question.

share|improve this answer
Jeff, I couldn't up your response but THANK YOU! I've been fighting this for three days now with no success and your response is the first one that actually gets my e-mails to send! Elegant or not, a send is better than not! – Beshoy Girgis Sep 5 '13 at 5:36

You have to remove the from your php.ini. And then modify the mail function for each script that sends mail for each host appropriately. That way you can pass the correct -f argument for each virtual host.

share|improve this answer
Sorry, I should have added that in my OP. I did remove the from the php.ini file prior to adding the mail.force_extra_parameters to the vhost's conf file. That still wasn't working. I found a way that worked for me that I'll be posting later tonight – Jeff Dec 8 '11 at 0:59
Please post it for another user seems to be having the same problem – adamo Dec 14 '11 at 7:10
Yes, this info would be greatly appreciated! :) – Minty Dec 14 '11 at 20:15
Whoops sorry for the delayed answer. I completely forgot about this question because I don't come over to SF too frequently – Jeff Feb 3 '12 at 3:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.