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 tried to sending out an email using php mail() function but it failed somehow, complaining that a real domain name is required. The following is observed in the maillog:

sendmail 4984 r25984: from=apache, size=273, class=0, nrcpts=1, msgid=<201.r25@localhost.localdomain>, relay=apache@localhost
sendmail 4985 r25985: ruleset=check_mail, arg1=, [], reject=553 5.5.4 ... Real domain name required for sender address
sendmail 4984 r25984:, ctladdr=apache (48/48), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30273, relay=[] [], dsn=5.6.0, stat=Data format error
sendmail 4984 r25984: r25984: DSN: Data format error

cron is able to send email to whenever there is a problem with logrotate. I am not sure why php is unable to do so. I tried making changes to the default configuration in ` with the following:


But, it doesn't seem to have any effect. The header from address in php mail function has already been set. I have also ensured that SELinux httpd_can_sendmail is enabled. What else to I need to do to get the mail delivered?

share|improve this question
You edited the, changed the lines localhost.localdomain and localhost to something meaningful and compiled the mc file into – fboaventura Mar 5 '13 at 11:58
@fboaventura, no, I uncommented the two lines by removing dnl in front of them. – Question Overflow Mar 5 '13 at 12:35
Can you add the relevant part of your php script, where you are invoking mail()? And, the isn't the proper configuration file, this file must be compiled into using the m4. – fboaventura Mar 5 '13 at 13:07
@fboaventura, thanks, I know that regarding the compilation requirement, I am able to get it work now. See my answer below. Thanks for your help :) – Question Overflow Mar 5 '13 at 13:12
up vote 5 down vote accepted

I think I have just solved it. I have the following in /etc/hosts: localhost.localdomain localhost

What I need is to place in front of the line with localhost.localdomain so that sendmail will think that it is using a real domain to send out the email.

share|improve this answer
You could definately accept your own answer is that was the solution ... As a sidenote, it is usually /etc/hosts (with an "s"), other than that: good answer! – Levit Jun 26 '15 at 9:41

You have to configure, in your scripts, the headers of your email to have From:

share|improve this answer
Sorry, I should have mentioned that this has already been set in headers. – Question Overflow Mar 5 '13 at 11:31

In your add:


Recompile, restart sendmail and you should be OK

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.