I have about 6 sites on my dedicated server (running centos5), and all emails sent using php's mail function are sent by nobody@servername.hostname.com e.g. "Received: from nobody by servername.hostname.com with local (Exim 4.69)". Is there any way to change this to show the appropriate domain?
4 Answers
From the PHP manual for mail():
Note: When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Like most php.ini settings this can overridden in the vhost config on Apache or via .htaccess or it can be set in the script (optionaly using auto_prepend) and since 5.3.0 via .user.ini files. But rather than explicitly setting the From, Reply-To and Return-path headers, it's simpler to just specify the recipient when the 'sendmail' program is invoked to process the message.
Assuming exim uses the standard flags on the commandline for its sendmail cli:
in php.ini:
sendmail_path = "/usr/sbin/sendmail -ffrom@example.com -t -i"
In httpd.conf
php_admin_value sendmail_path "/usr/sbin/sendmail -ffrom@example.com -t -i"
In .htaccess.conf
php_value sendmail_path "/usr/sbin/sendmail -ffrom@example.com -t -i"
(note your sendmail path may be different from that shown)
C.
It is possible to overwrite the value only with php_admin_value in the apache site conf. It can`t be set with php_value
- 1
You can use some wrapper script, for example my php-secure-sendmail. It allows you to log every sent email (virtualhost,date/time,recipient), limit number of sent emails per hour/day by virtualhost, set envelope-sender and many more...
- 1,610