Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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=, relay=mydomain.com [127.0.0.1], reject=553 5.5.4 ... Real domain name required for sender address
sendmail 4984 r25984: to=external@server.com, ctladdr=apache (48/48), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30273, relay=[127.0.0.1] [127.0.0.1], dsn=5.6.0, stat=Data format error
sendmail 4984 r25984: r25984: DSN: Data format error

cron is able to send email to external@server.com 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 `sendmail.mc with the following:

MASQUERADE_AS(`mydomain.com')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl
MASQUERADE_DOMAIN(mycom)dnl

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 sendmail.mc, changed the lines localhost.localdomain and localhost to something meaningful and compiled the mc file into sendmail.cf? –  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 sendmail.mc isn't the proper configuration file, this file must be compiled into sendmail.cf 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

3 Answers 3

You have to configure, in your scripts, the headers of your email to have From: sender@domain.com.

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

I think I have just solved it. I have the following in /etc/host:

127.0.0.1 ww.mydomain.com test.mydomain.com
127.0.0.1 cdn.mycdn.com
127.0.0.1 localhost.localdomain localhost myserver.com

What I need is to place myserver.com 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

In your sendmail.mc add:

LOCAL_CONFIG
Djmyserver.com

Recompile sendmail.cf, restart sendmail and you should be OK

share|improve this answer

Your Answer

 
discard

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.