We have an internal network, which has its own DNS servers for that network. Internet addresses are not resolved on that network, except for some servers which have internet access.
One of such servers with internet access is acting as a relay host for others so they can send e-mails (reports, logwatch,...) to admins. This relay server has also one relay server defined on the internet, but that is not relevant. It works fine that way except for one strange exception.
I have Oracle Linux 8 on one of the servers that uses relay host. Usually I have to add
to sendmail.mc, but on this one it does not work. I can't get it to use the relay. It always relays to
root@localhost. At least that is what it writes to
/var/log/maillog. I tried
SMART_HOST, and many other configuration settings.
When I test with
mail -s test firstname.lastname@example.org
The maillog reports something like this:
Aug 31 09:44:14 hostname sendmail: 17V9iE4L694964: email@example.com, size=15, class=0, nrcpts=1, msgid=<202108310944.17V9iE4L694964@hostname.internal.domain>, relay=root@localhost Aug 31 09:44:14 hostname sendmail: 17V9iE4L694964: firstname.lastname@example.org, delay=00:00:00, mailer=relay, pri=30015, dsn=4.4.3, stat=queued
The message does not end up in queue in that case.
I tried also sending the mail with
(echo subject: test; echo) | /usr/lib/sendmail -Am -v -email@example.com firstname.lastname@example.org
With that command I get the answer
internet-domain.com: Name server timeout email@example.com... Transient parse error -- message queued for future delivery firstname.lastname@example.org... queued
Log, in this case, is practically the same
Aug 31 11:42:43 hostname sendmail: 17VBghos698071: email@example.com, size=15, class=0, nrcpts=1, msgid=<202108311142.17VBghos698071@hostname.internal.domain>, relay=root@localhost Aug 31 11:42:43 hostname sendmail: 17VBghos698071: firstname.lastname@example.org, delay=00:00:00, mailer=relay, pri=30015, dsn=4.4.3, stat=queued
The message enters the queue with sendmail command, but stays there forever.
It is correct that internet-domain.com cannot be resolved. I guess the problem is that internet-domain.com cannot be resolved, and sendmail does not use SMART_HOST in that case. How can I force sendmail to use the SMART_HOST always also with unresolved domains for addressee? It should be the job of relays to reject messages with wrong destination addresses.
I have identicaly configured sendmail on CentOS 8, which sends e-mails via relay just fine. The difference is that CentOS 8 can resolve internet domains.
An update. If I send a mail to an internet domain, the sendmail uses localhost as a relay, and mail goes nowhere, as described above.
If I send it to a domain, that can be resolved internaly by internal DNS, it is sent to a relay server defined as SMART_HOST. Relay server relays it. However, that is not a valid internet domain and an e-mail account does not exists. Therefore, the mail with wrong address cannot be delivered, and I get a report about that with the undeliverable mail as an attachment.
Another update. If I add
/etc/mail/sendmail.mc, some mails get through. If I send to a valid internet mail, it still doesn't get through. However, I have an alias for
/etc/aliases which points to the same address I am testing with mail commands. If I send a mail to
root, it gets through, because aliases redirect it. In that case, internet e-mail does not confuse sendmail and the smart host is used for relaying. It is enough for me, as I only need admin mails for root from this server, but the problem is still not fully solved.
# Person who should get root's mail root: email@example.com