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

We have a Linux server with a single site set up on it (, down the road we may set up additional sites.

When we send an email through php it comes from
We would like to change it to, but also make it so that when we add down the road, we can have the default email set to for instance.

I tried setting it in .htaccess, but that didn't seem to work. maybe I did it wrong.

php_value force_sender

Linux noob, so what's the best way to do this?

share|improve this question last parmater to function mail: -f set envelope sender. – RJS Oct 5 '12 at 13:54
Yeah, I've used -f, I'm just hoping there is a way to set a default value that's different for each site. Otherwise we'll have to set the default to something that isn't site specific. – AndyD273 Oct 5 '12 at 14:38
up vote 1 down vote accepted

the force_sender option probably only works when sending mails over SMTP, not via the sendmail binary (default).

you can try to pass the envelope sender via an additinal -f parameter in mail():


not all installations allow -f overrides though. if it doesn't work, use one of the many helper classes like phpmailer which send via smtp and allow you to specify the envelope sender.

share|improve this answer
Yeah, I know about that... I was just hoping to have a way to make a different default for each domain, and then use the -f to customize it as needed. – AndyD273 Oct 5 '12 at 14:31
maybe you could try overriding the sendmail_path per domain like explained in the top answer here:… - haven't tried myself though – Gryphius Oct 5 '12 at 15:05

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.