0

I'm trying to disable local mail delivery on my sendmail server (CentOs 8). I've read many posts about this (for example: Disable local delivery in Sendmail) but non of the awnsers seem to work.

I basically have a standard sendmail installation and using Google Apps for handling mail for this domain. Sending mail works fine however when sending mail to the local domain the mail is not being send. The sendmail logging will always give the following error:

May 15 11:21:03 example sendmail[8443]: 04F9L3Ru008443: 04F9L3Rv008443: return to sender: User unknown
May 15 11:21:03 example sendmail[8443]: 04F9L3Rv008443: to=root, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32691, relay=aspmx.l.google.com. [74.125.143.27], dsn=5.1.1, stat=User unknown

Any other mail is delivered fine. When running:

echo '$={w}' | /usr/sbin/sendmail -bt

The domain I'm trying to send to is listed here, thus being treated as locally.

I tried to add:

define(`MAIL_HUB', `example.com.') dnl
define(`LOCAL_RELAY', `example.com.') dnl

In de sendmail.mc file, recompling and restarting the serivce but this does not work. I always get the error mentioned above.

I also tried various other things like:

  • Adding the server hostname/ip in /etc/hosts (mentioned in other topics)
  • Not probing local interfaces (define(confDONT_PROBE_INTERFACES',True'))
  • Commenting out the domain name in local-host-names (/etc/mail)

DNS and other settings seem to be correct. When using DIG I get the correct MX records. Also, when looking at the log (see above) it's connecting to the Google MX records.

I'm sure i'm missing something but can't figure it out.

Update: The problem is that the hostname of the server is the same as the sending domain. But I can't figure out how to work around this without renaming the hostname of the server.

Thanks for your time!

0

1 Answer 1

0

I did find a solution to fix this problem. Not sure if it's the best solution but it works.

Add the following to the sendmail.mc file:

LOCAL_CONFIG
Kbestmx bestmx -T.TMP

LOCAL_RULE_0
R $* < @ example.com. > $*            $#esmtp $@ [$(bestmx example.com. $)] $: $1 < @ vrijevakantiehuizen.nl. > $2

Do note that copy pasting this might not work. The space beween the last line $* and $#esmtp are 2 tabs (no spaces).

Now sendmail will deliver the mail for example.com to the best MX record it can find instead of treating this domain as local.

Don's forget to recompile the file (command: /etc/mail/make) and restart sendmail. After this my problem is resolved.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .