Port 587 (SMTP Submission)
Key facts
- Port
- 587
- Protocols
- TCP
- Range
- System port (Well-Known), 0-1023
- IANA service name
- submission
IANA assigns ports in this range to well-known services, under RFC 6335.
About port 587
Port 587 is the standard port for sending mail from an email client or a website to the mail server (Message Submission), and it runs over TCP. The connection starts unencrypted and switches to an encrypted connection with the STARTTLS command, and then the user authenticates with a username and password.
The service is defined in RFC 6409, and IANA registers port 587 for the submission service.
What port 587 is used for
Port 587 was designed to separate mail sent by users from mail relayed between servers, which uses port 25:
- Email clients and phones: in the outgoing mail server settings, choose port 587 and STARTTLS security.
- Websites and applications: SMTP plugins, mail libraries, and sending services connect on port 587 with authentication.
- Mail server: accepts on port 587 only messages from authenticated users, and can apply its own sending limits and checks to them.
Port 587 in the firewall
On a mail server that serves users, open port 587 to incoming traffic, usually alongside port 465. Since users send mail from different networks, it's usually not possible to limit the port to specific IP addresses.
- UFW:
ufw allow 587/tcp - firewalld:
firewall-cmd --permanent --add-port=587/tcp
A web server that isn't a mail server doesn't need port 587 open to incoming traffic. When the site sends mail through another mail server, only an outgoing connection to port 587 is needed.
Risks and security
Since the connection on port 587 starts unencrypted, it's important that the server requires STARTTLS before authentication, so the username and password don't travel as plain text.
- Configure the server to allow authentication only after switching to an encrypted connection.
- In your email client, choose the STARTTLS option itself, not the option that encrypts the connection only when the server offers encryption.
- Use strong passwords for mailboxes, and temporarily block addresses that make repeated failed authentication attempts, for example with fail2ban.
- Set a sending limit for each account, to protect the mail server's reputation.
Commands to check and configure
-
ss -tlnp | grep ':587 'Checks whether the mail server is listening on port 587.
-
nc -zv mail.example.com 587Checks whether port 587 on the mail server is open and reachable from your computer.
-
openssl s_client -connect mail.example.com:587 -starttls smtpConnects to port 587, switches to an encrypted connection with STARTTLS, and shows the mail server's certificate.
-
telnet mail.example.com 587Opens a manual connection to the mail server. After you send EHLO with your domain name, the server lists its capabilities, including STARTTLS.
-
ufw allow 587/tcpOpens port 587 to incoming traffic (UFW).
-
firewall-cmd --permanent --add-port=587/tcpOpens port 587 to incoming traffic in firewalld. Then run firewall-cmd --reload.
Port 587 in the IANA registry
| Port | Protocol | Service | IANA registry description |
|---|---|---|---|
| 587 | TCP | submission | Message Submission |
| 587 | UDP | submission | Message Submission |
Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)
Port 587 FAQ
Which security setting do I choose in my email client for port 587?
Choose STARTTLS. The connection starts unencrypted and immediately switches to an encrypted connection, before the username and password are sent. The SSL/TLS setting is for port 465, not port 587.
What's the difference between port 587 and port 25?
Port 587 is for people sending mail, with username and password authentication. Port 25 is for relaying mail between mail servers. That's why you set port 587 or 465 in an email client and on a website, not port 25.
Is port 587 as secure as port 465?
Yes. When the server and the client require STARTTLS, port 587 is as secure as port 465. According to RFC 8314, when both sides require encryption before sending, there's no significant difference in security between STARTTLS on port 587 and the connection encrypted from the start on port 465.
Can I use port 587 to send mail from a website?
Yes. This is one of the most common ways to send mail from a website: in an SMTP plugin or in the system settings, set the mail server, port 587, STARTTLS encryption, and the mailbox details. This way, messages leave from an authenticated mail server and are more likely to reach their destination.