Sendmail Connection closed by foreign host

I installed and configured sendmail, the same as on my working RHEL7 box. When I test it with telnet, I get the following.

telnet 25
Connected to
Escape character is ‘^]’.
421 4.3.2 Service not available
Connection closed by foreign host.

Does the above mean the smtp server is not accepting requests from my server?

The port is listening as the same as on the server where it works.

ss -lntu | grep ‘:25’
tcp LISTEN 0 10*

Its only listening on localhost so use localhost or with telnet or configure sendmail to listen on specific ip.

Thanks for the reply.
My other servers only listen on localhost (since that was the default setup from the install of sendmail) and they are able to sendmail. How do I configure sendmail to listen on a specific IP? By specific IP, do you mean the rocky linux box’s IP?

OK, it wasn’t clear from your telnet command as you X’d out the IP address. You could have just left it as localhost or since it’s not a risk.


telnet 25

resolves to localhost, then if you are getting service not available then it means you have misconfigured sendmail. If you copied sendmail config files from RHEL7 to Rocky 8 or 9 then you shouldn’t do that. You should just edit the one supplied by the distribution and add the configuration you need manually. If you didn’t do this, then you’ll need to check the sendmail configuration and fix it. Check /var/log/messages or /var/log/maillog for errors after restarting sendmail.

If you are only going to use the server locally, then leaving it on localhost is OK. If you want to send to the world though, then you shouldn’t be doing it that way. SMTP servers will usually be checked against DNS and PTR records, and if they are not matched or inaccessible, then your mail maybe rejected.

Since we don’t have enough information about your configuration or what you are attempting to do, it’s almost impossible to help. Please post a lot more information including the steps you have done to install/configure sendmail on the machine it is failing on.

@iwalker Sorry to confuse. The Trying xxx ip line is the ip for the smtp server (i think), which is separate from the rocky box.

@iwalker I did not copy RHEL7 config files to the rocky box, I edited the supplied file /etc/mail/ from the install of sendmail by defining the SMART_HOST, which I defined with the same as on the working server.

No other files were edited when I set up the RHEL7 server.

maillog has the following. Does this mean the server is not “known” on the network?
sendmail[93392]: My unqualified host name (xxxxxxsrv) unknown; sleeping for retry

Yeah, this is where I mention issues with running SMTP servers on localhost. SMTP Servers accepting emails from other SMTP servers do actually prefer to be able to get a connection to that server. In fact some will drop your connection and not allowing send/receive if they cannot connect to you. Some servers also do sender verification before accepting emails. This means they connect to your server via SMTP to check/verify if that email address exists before accepting it. Also if the server sending doesn’t have a proper FQDN then it can also be rejected.

It could well be because your server doesn’t have a fully qualified hostname in the format of then you can have issues sending emails from it. So you would need to fix that first, considering the errors in your log files. And you may have to reconfigure sendmail to listen on or the IP address of the server instead of localhost. But you’ll only know that once you go through the server configuration and attempt to send emails, and see whether it is accepted or not via the server you are attempting to relay to. The other question is, do you need to provide a username/password to connect to that SMTP server to relay emails? That could also be a problem.

On your RHEL7 box, do:

hostname -f

to find out the hostname and FQDN and do the same on the other server that doesn’t work.

@iwalker it looks like the hostname is the issue. my host name is missing the domain portion. After an install can I safely change the name by some command?

Yes, you can use ``hostnamectl```:

hostnamectl set-hostname

you can check and verify after with:


you can do that on both servers just to make sure.

@iwalker I changed the server name which resolved the My unqualified host name issue in the maillog

maillog now reports:
reply=421 4.3.2 Service not available, stat=Deferred: 421 4.3.2 Service not available

Does this sound like an issue on my box or the smtp server?

@iwalker Problems solved. The serve’s ip address was not whitelisted. Perhaps the hostname would have still been an issue, but at least it’s working now.

1 Like