Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As a normal user I can send email, either from the commandline or from PHP. But when a cron job has error output, sending of that email fails (I have a MAILTO=me@example.com at the top of the crontab). The same happens for sending from the commandline as root (*).

I've tracked this down to: when the emails work the From and Return Path headers are set to me@valid.domain.com. That domain is the one set in /etc/mail/sendmail.mc, i.e. I have these three lines:

FEATURE(`allmasquerade') dnl
MASQUERADE_DOMAIN(`valid.domain.com.')dnl
MASQUERADE_AS(valid.domain.com)dnl

For the emails that fail, the From and Return Path headers are set to root@machinename.example2.com. example2.com exists, but machinename has no DNS entry. Therefore the email gets refused with a 550. machinename.example2.com is the first entry in /etc/hosts for 127.0.0.1.

I suspect changing /etc/hosts with valid.domain.com might work but this is a production web server and I don't want to break anything else. It also feels like the wrong place to solve an email problem. So I'm hoping it is a sendmail or cron setting I need. (On another machine, ubuntu/postfix, I seem to have created /etc/postfix/sender_canonical to do this.)

OS: Centos 5.6

Mail Server: sendmail 8.13.8

*: but in that case the error correctly gets sent to me@example.com, as I have set the alias for root in /etc/aliases. This doesn't happen with the cron emails though; those bounce emails get put in my local unix mailbox.

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.