Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have about 6 sites on my dedicated server (running centos5), and all emails sent using php's mail function are sent by e.g. "Received: from nobody by with local (Exim 4.69)". Is there any way to change this to show the appropriate domain?

share|improve this question
You could use header rewriting but that will not work as all mail is being submitted by the same user (nobody) – topdog Jul 30 '10 at 5:07

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 -t -i"

In httpd.conf

php_admin_value sendmail_path "/usr/sbin/sendmail -t -i"

In .htaccess.conf

php_value sendmail_path "/usr/sbin/sendmail -t -i"

(note your sendmail path may be different from that shown)


share|improve this answer
This is incorrect - you can't set sendmail_path per domain, it's systemwide: – Farkie Dec 18 '15 at 10:04

You must use the -f option of php mail function.

share|improve this answer

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...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.