5

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?

Thanks

Jason
  • 361
  • 6
  • 19
  • 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 01: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 09:45

1 Answers1

6

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 sendmail.mc 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:

LOCAL_CONFIG
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:

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

  • Note 2: Do not copy paste the rules in your sendmail.mc. 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 sendmail.mc, you have to build sendmail.cf 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.

adamo
  • 6,867
  • 3
  • 29
  • 58
  • 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 sendmail.mc 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 07: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 03 '13 at 21:53
  • LHS: `R $* < @ example.com. > $*` – adamo Sep 05 '13 at 13:16