Sendmail remote connection refusedPosted in Email Servers -
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 laptop.electrictoolbox.com 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 127.0.0.1: 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 sendmail.cf file contains all the instructions sendmail needs to run as you intend it to. It is generated automatically from the sendmail.mc file, which is a much easier to read and understand configuration file. Whereever possible you should always modify the snedmail.mc file rather than the sendmail.cf file. However, the are circumstances when someone has changed the sendmail.cf file manually and therefore you need to edit that again to prevent overwriting their changes.
To modify sendmail to accept remote connections in the sendmail.cf file, comment out (or deletd) the following line:
O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA
The commented out version of this line would then look like so:
#O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, 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 sendmail.mc file instead. It's always a good idea to make a backup copy of the sendmail.cf file though in case something goes wrong and there had been changes made to that file that are not in the sendmail.mc file.
As with the sendmail.cf file you need to comment out (or delete) the same option. In the sendmail.mc file this looks like so:
After commenting out the line it will now look like so:
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
You now need to compile this file into a new sendmail.cf file by issuing the following command:
m4 sendmail.mc > sendmail.cf
and then restarting sendmail. Remember it's important to make a backup copy of the sendmail.cf file first so you can revert back to it if sendmail stops working like it did before.