0

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

When we send an email through php it comes from www-data@site1.com
We would like to change it to contactus@site1.com, but also make it so that when we add site2.com down the road, we can have the default email set to admin@site2.com for instance.

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

php_value force_sender contactus@site1.com

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

AndyD273
  • 209
  • 1
  • 10
  • http://php.net/manual/en/function.mail.php last parmater to function mail: -f set envelope sender. – RJS Oct 05 '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 05 '12 at 14:38

1 Answers1

1

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():

mail('recipient@example.com',$subject,$body,$yourheaders,'-f sender@example.net');

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.

Gryphius
  • 2,710
  • 1
  • 18
  • 19
  • 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 05 '12 at 14:31
  • maybe you could try overriding the sendmail_path per domain like explained in the top answer here: http://serverfault.com/questions/165499/configuring-php-mail-per-domain - haven't tried myself though – Gryphius Oct 05 '12 at 15:05