Sendmail remote connection refused

If you can connect to sendmail locally but not remotely then you need to modify the sendmail configuration slightly. For normal workstation use, you would not want sendmail to be opened up for remote connections but would if it is being used as a mail server. (Note remote connection issues can always be firewall related).

You can test connecting to sendmail locally by issuing the command

telnet localhost 25

Note that we are not actually telnetting but attempting to establish a connection on port 25, which is the port mail transfer agents listen on for incoming connections.

If you get something like the following then you were successfully able to connect. To disconnect from sendmail type "quit" and hit enter.

Connected to localhost.
Escape character is '^]'.
220 ESMTP Sendmail 8.12.8/8.12.8; Sun, 30 Nov 2003 13:19:45 +1300

If you could not connect then you’ll see something like the following instead. If you get this then you probably don’t have sendmail running, or the appropriate entry in your inetd or xinetd settings, depending on how your machine is configured. Fixing this sort of problem is not within the scope of this article.

telnet: connect to address Connection refused

Whether attempting to connect to a local or remote server you will get the same sort of result, either the connection will be refused or you will be greeted by the mail server. To allow access to incoming remote connections, you need to modify the sendmail configuration.

There are two ways to modify sendmail’s configuration file. The file contains all the instructions sendmail needs to run as you intend it to. It is generated automatically from the file, which is a much easier to read and understand configuration file. Whereever possible you should always modify the file rather than the file. However, the are circumstances when someone has changed the file manually and therefore you need to edit that again to prevent overwriting their changes.

To modify sendmail to accept remote connections in the file, comment out (or deletd) the following line:

O DaemonPortOptions=Port=smtp,Addr=, Name=MTA

The commented out version of this line would then look like so:

#O DaemonPortOptions=Port=smtp,Addr=, Name=MTA

Restart sendmail after doing this and you should now be able to connect to sendmail from a remote machine. If you commented out the line rather than deleted it you are then able to easily revert back to your previous configuration.

The preferred option is to edit the file instead. It’s always a good idea to make a backup copy of the file though in case something goes wrong and there had been changes made to that file that are not in the file.

As with the file you need to comment out (or delete) the same option. In the file this looks like so:

DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')

After commenting out the line it will now look like so:

dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')

You now need to compile this file into a new file by issuing the following command:

m4 >

and then restarting sendmail. Remember it’s important to make a backup copy of the file first so you can revert back to it if sendmail stops working like it did before.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s