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 can't seem to send mail through my php scripts or through the linux console on my Centos 5.5 LAMP server, when the email is addressed to go to a domain that is hosted by my box.

I think it is something to do with the email routing internally, or the DNS servers that the box uses not reporting the correct MX records.

Basically my box doesn't host any mail, it's all hosted on google apps. My name servers are hosted by a 3rd party provider and I am using webmin. Webmin doesn't recognise the settings on the 3rd party provider.

I'm unsure how to fix this. Previously when I had this problem on a cpanel server, I would edit the remotedomains and localdomains files, moving domains from one file to another and it would fix the problem.

What information do I need to provide for anyone to work out what the issue is?


share|improve this question
I agree that it has something to do with the local domains. I am a postfix kind of guy though, so I cannot help you on how it works with sendmail. However, if it detects the domain locally it will not try to route it externally. – Frands Hansen Dec 26 '11 at 1:45
Please give us informations about the "domain that is hosted on your box" and the domains you have configured in google apps. Basically what are the MX records for the "domain that is hosted on your box" ? – Olivier S Dec 26 '11 at 9:45
up vote 4 down vote accepted

If you run sendmail -bt (test mode for sendmail) and then type $=w you will see that the domains that you have problem with are listed. This is because sendmail believes that the mail addressed to said domains must be delivered locally in the box, instead of sending it to Google. So what you have to do is to modify your in two places (or add them if they do not exist).

First in the LOCAL_CONFIG section add a map that looks up the best MX for a domain:

Kbestmx bestmx -T.TMP

Next, in the LOCAL_RULE_0 section where sendmail selects a delivery agent use the map above to route mail to Google:

R $* < @ > $*           $#esmtp $@ [$(bestmx $)] $: $1 < @ > $2
  • Note 1: replace with the domain in question

  • Note 2: Do not copy paste the rules in your Type them for the left and the right hand side of the rules are not separated with spaces but with tab characters.

  • Note 3: After you've done editing, you have to build and then restart sendmail. I do not know how this is done in CentOS. I run Debian and execute sendmailconfig

You can read a more detailed explanation on the problem in my blog post here.

share|improve this answer
I edited my local domains hosts file and removed the domains and added them to the outgoing domains hosts file and it seems to work. Your answer didn't exactly work because my file doesn't have a local config section or a local rule section. Also it has "dnl" at the start of every line. – Jason Dec 26 '11 at 23:26
Like I said, if said sections do not exist in your .mc, you can add them. dnl is an m4 directive that instructs to "delete from here until newline" so you can treat it as a comment identifier. – adamo Dec 27 '11 at 7:37
Its not clear to me where the LHS should be separated from the RHS. I have tried putting a tab in various spots, but none of them worked for me. ??? – Octopus Sep 3 '13 at 21:53
LHS: R $* < @ > $* – adamo Sep 5 '13 at 13:16

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.