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
define(`SMART_HOST', `relay_hostname')dnl
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 [relay_hostname]
, relay:[relay_hostname]
for SMART_HOST
, and many other configuration settings.
When I test with
mail -s test name@internet-domain.com
The maillog reports something like this:
Aug 31 09:44:14 hostname sendmail[694964]: 17V9iE4L694964: from=root@hostname.internal.domain, size=15, class=0, nrcpts=1, msgid=<202108310944.17V9iE4L694964@hostname.internal.domain>, relay=root@localhost
Aug 31 09:44:14 hostname sendmail[694964]: 17V9iE4L694964: to=name@internet-domain.com, 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 -froot@hostname.internal.domain name@internet-domain.com
With that command I get the answer
internet-domain.com: Name server timeout
name@internet-domain.com... Transient parse error -- message queued for future delivery
name@internet-domain.com... queued
Log, in this case, is practically the same
Aug 31 11:42:43 hostname sendmail[698071]: 17VBghos698071: from=root@hostname.internal.domain, size=15, class=0, nrcpts=1, msgid=<202108311142.17VBghos698071@hostname.internal.domain>, relay=root@localhost
Aug 31 11:42:43 hostname sendmail[698071]: 17VBghos698071: to=name@internet-domain.com, 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
FEATURE(nocanonify)dnl
to /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 root
in /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.
/etc/aliases:
# Person who should get root's mail
root: name@internet-domain.com
relay_hostname
is a placeholder for your real machine name. Is that machine name a fully qualified name, or one with no dots? If it's the latter, does the fully qualified variant (with whatever domain is defined in your resolv.conf) work too? – Chris Davies Aug 31 '21 at 13:00/etc/mail/aliases
. – Jim L. Sep 02 '21 at 21:58