在PHP中为多个域设置mail()

我们有一台Linux服务器,在其上build立了一个站点(site1.com),随后我们可以build立更多的站点。

当我们通过php发送邮件时,它来自[email protected]
我们想将其更改为[email protected],但也可以这样做,当我们在路上添加site2.com时,我们可以将默认电子邮件设置为[email protected]

我尝试在.htaccess中设置,但似乎没有工作。 也许我做错了。

php_value force_sender [email protected] 

Linux noob,那么做这件事的最好方法是什么?

force_sender选项可能只适用于通过SMTP发送邮件,而不是通过sendmail二进制文件(默认)。

您可以尝试通过mail()中的additinal -fparameter passing信封发件人:

mail('[email protected]',$subject,$body,$yourheaders,'-f [email protected]');

不是所有的安装都允许-f覆盖。 如果它不起作用,请使用通过smtp发送的诸如phpmailer之类的许多帮助程序类,并允许您指定信封发件人。