Recently, I have faced the below issue with a new Sendmail installation on a Linux system. While sending emails to a specific domain like user@domain.com are showing the error “stat=User unknown“.

Advertisement

The issue was happening for a specific domain only. Sending emails to other domain were working properly.

The log file entries are looks like below:

Jan  7 08:36:04 tecadmin sendmail[22497]: 1078a4RD022497: from=www-data, size=679, class=0, nrcpts=1, msgid=, relay=www-data@localhost
Jan  7 08:36:04 tecadmin sendmail[22497]: 1078a4RD022497: to=user@domain.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30679, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
Jan  7 08:36:04 tecadmin sendmail[22497]: 1078a4RD022497: 1078a4RE022497: DSN: User unknown

Solution:

After troubleshooting the issue, we found that this happens because your domain name matches either your server’s hostname or a setting in Sendmail’s config file. In that case, we can configure Sendmail to force send emails to your actual mail server instead of itself.

Follow the below instructions:

  1. Edit /etc/mail/sendmail.mc and add the following lines at the end:
    sudo vim /etc/mail/sendmail.mc 
    

    Add the following entries:

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

    Make sure to change your domain name end with the trailing dot!

  2. Now, run the sendmailconfig command, so that the changes take effect, and restart sendmail just to be 100% sure:
    sudo sendmailconfig 
    

    Press ‘Y’ for all confirmation prompted.

  3. Finally, restart the Sendmail service to apply changes.
    sudo systemctl restart sendmail 
    

All done. Again send an email and the email should be delivered to the actual mailbox.

Share.

2 Comments

  1. Interesting. I’ve been using email sendmail since 2005 and have not had these 2 entries in my sendmail.mc file.

    The this week after patching server (which I do regularly), the relay stopped working and it was only after I found your article and added the fix you suggest here that it started working again. Very odd that I’ve escaped this issue for so long!

Leave A Reply


Exit mobile version