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
  • 207
  • 1
  • 11

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,760
  • 1
  • 20
  • 21