我在我的专用服务器(运行centos5)上有大约6个站点,所有使用php的邮件function发送的邮件都通过[email protected]发送,例如“Received:from nobody by servername.hostname.com with local(Exim 4.69) ”。 有没有办法改变这个来显示相应的域名?
从mail()的PHP手册 :
注意:发送邮件时,邮件必须包含From头。 这可以使用additional_headers参数来设置,或者可以在php.ini中设置默认值。
像大多数php.ini设置一样,这可以在Apache的vhostconfiguration中或通过.htaccess覆盖,也可以在脚本中设置(可select使用auto_prepend),以及通过.user.ini文件从5.3.0 设置 。 但不是明确地设置From,Reply-To和Return-path头,只要在调用“sendmail”程序来处理消息时指定收件人就简单多了。
假设exim使用命令行上的标准标志来发送sendmail cli:
在php.ini中:
sendmail_path = "/usr/sbin/sendmail [email protected] -t -i"
在httpd.conf中
php_admin_value sendmail_path "/usr/sbin/sendmail [email protected] -t -i"
在.htaccess.conf中
php_value sendmail_path "/usr/sbin/sendmail [email protected] -t -i"
(注意你的sendmailpath可能与图中所示不同)
C。
你必须使用php邮件function的-f选项。
你可以使用一些包装脚本,例如我的php-secure-sendmail 。 它允许您通过虚拟主机logging每个发送的电子邮件(虚拟主机,date/时间,收件人),限制每小时发送的电子邮件数量,设置信封发件人等等。