Sendmail config when MX record points to another server

If your domain mail is hosted on mail server in a different domain, you should tell your sendmail about it. Otherwise if you try to send a mail to a user in your local domain, you will get an error from sendmail at /var/log/mail.log:

User unknown.

Sendmail looks for the recipient on your local server and can’t find them, because the mail server is on a different IP address. Tell sendmail to look for users of your domain on the remote server.

Open /etc/mail/sendmail.mc for editing:

sudo nano /etc/mail/sendmail.mc

Add these two lines to the end of the file:

define(`MAIL_HUB', `your.domain.com.')dnl
define(`LOCAL_RELAY', `your.domain.com.')dnl

Press “Ctrl + X” when you are done and answer “Y” for question about saving a file.

Now we should reload sendmail service:

service sendmail reload

And try to send mail again. If you have done everything right, emails should go through remote mail server without errors.

I do product consulting, build MVPs and teach people to build products themselves. Work with me →