Sendmail is an email server application that is available for many operating systems. It will listen on TCP port 25 for connections from other mail servers that use the Simple Mail Transfer Protocol for email transmissions. As a message submission agent (MSA), another common port it listens on is TCP port 587 for email transmissions from users' email clients. On a Linux system you can use the netstat or ss commands to determine if a system is listening for connections on a particular port. When I checked a Sendmail server to determine whether it was listening on port 587, I could see that it was not listening on that port, though that was needed.
# netstat -an | grep 587 # ss -ln | grep ":587 " #
When I searched /etc/mail/sendmail.mc for
RELAY_MAILER_ARGS, I saw the following
lines, which are needed to have Sendmail listen for email transmissions
from users on TCP port 587, were already present and were not commented out:
define(`RELAY_MAILER_ARGS', `TCP $h 587') define(`ESMTP_MAILER_ARGS', `TCP $h 587')
When I searched for DAEMON_OPTIONS, I saw the following:
dnl # The following causes sendmail to additionally listen to port 587 for dnl # mail from MUAs that authenticate. Roaming users who can't reach their dnl # preferred sendmail daemon due to port 25 being blocked or redirected find dnl # this useful. dnl # dnl DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl
I removed the dnl from the begining of the line so that
I then had the line below, instead:
DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl
I then rebuilt /etc/sendmail/mc and restarted the Sendmail
service.
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf # service sendmail restart Redirecting to /bin/systemctl restart sendmail.service #
I could then see that the system was listening for connections on port 587.
# netstat -an | grep 587 tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN # ss -ln | grep ":587 " tcp LISTEN 0 10 *:587 *:* #
From the mail server, I was then able to establish a telnet connection to port 587 on the server's localhost address, 127.0.0.1, but not port 25.
# telnet 127.0.0.1 587 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 example.com ESMTP Sendmail 8.14.7/8.14.7; Sat, 14 Jun 2025 14:14:17 -0400 quit 221 2.0.0 example.com closing connection Connection closed by foreign host. # telnet 127.0.0.1 25 Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused #
When I checked, I found the system was no longer listening for connections on port 25, which it needs to listen on to receive email from other email servers.
# ss -ln | grep ":25 "
# ss -ln | grep ":587 "
tcp LISTEN 0 10 *:587 *:*
#Looking at the /etc/mail/sendmail.mc file again, I saw the
following:
dnl # The following causes sendmail to only listen on the IPv4 loopback address dnl # 127.0.0.1 and not on any other network devices. Remove the loopback dnl # address restriction to accept email from the internet or intranet. dnl # dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
I changed the line to the following:
dnl DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
I then saw that the system was listening on both port 25 and port 587 after I restarted Sendmail.
# service sendmail restart Redirecting to /bin/systemctl restart sendmail.service # ss -tuln | grep 25 tcp LISTEN 0 10 *:25 *:* # ss -tuln | grep 587 tcp LISTEN 0 10 *:587 *:* #
The server sends email to other email servers via a smarthost, so the following line was also in the sendmail.mc file:
define(`SMART_HOST', `[smtp.sparkpostmail.com]')dnl