What is the difference between ports 465 and 587?
Asked Answered
M

6

283

These ports 465 and 587 are both used for sending mail (submitting mail) but what is the real difference between them?

Manutius answered 3/4, 2013 at 19:40 Comment(4)
The only difference is formalized standards and 465 port is for legacy support?Manutius
iana's "Service Name and Transport Protocol Port Number Registry" is the formal guide to the recommended use of ports; the use of 465 for SMTP over SSL is unofficial. Read about Ports in SMTP. iana's official usage is not always the same for both the TCP and UDP transport protocols. N.B.: if you are the SMTP server administrator, YOU control which port(s) are used; if you are the client, you get only ports made available to you.Droughty
related: #3485447Sterigma
related: fastmail.com/help/technical/ssltlsstarttls.htmlCyma
C
262

SMTP protocol: smtps (port 465) v. msa (port 587)

Ports 465 and 587 are intended for email client to email server communication - sending out email using SMTP protocol.

Port 465 is for smtps
SSL encryption is started automatically before any SMTP level communication.

Port 587 is for msa
It is almost like standard SMTP port. MSA should accept email after authentication (e.g. after SMTP AUTH). It helps to stop outgoing spam when netmasters of DUL ranges can block outgoing connections to SMTP port (port 25).
SSL encryption may be started by STARTTLS command at SMTP level if server supports it and your ISP does not filter server's EHLO reply (reported 2014).


Port 25 is used by MTA to MTA communication (mail server to mail server). It may be used for client to server communication but it is not currently the most recommended. Standard SMTP port accepts email from other mail servers to its "internal" mailboxes without authentication.

Cerebrovascular answered 3/4, 2013 at 19:59 Comment(8)
Standard SMTP port accepts email from other mail server without authentication - is not actually technically correct. Standard 25 port can transfer mail both using authentication and not depending on the configuration of MTA.Manutius
@Ilia standard SMTP port of normal MTA can not reject (all) unauthenticated SMTP connections.Cerebrovascular
How about Postfix? It doesn't let relaying mail by default but only for connections from same network?Manutius
@Ilia There is also incoming mail to local email domains.Cerebrovascular
Note that while unofficial, port 465 offers the end user more assurance that they are really talking over an encrypted channel. Port 587, with TLS being optional, means an end user could be providing their credentials over an unencrypted channel. With email clients being what they are, you cannot guarantee the MUA is going to even alert the user that the connection has been downgraded.Kieffer
Since [RFC 8314][tools.ietf.org/html/rfc8314#section-7.3], port 465 is for msa over TLS.Teacart
Is it better to use SMTPS or MSA?Bartlett
@AaronFranke IMHO it better to choose SMTPS when SMTPS and MSA are available.Cerebrovascular
G
134

587 vs. 465

These port assignments are specified by the Internet Assigned Numbers Authority (IANA):

  • Port 587: [SMTP] Message submission (SMTP-MSA), a service that accepts submission of email from email clients (MUAs). Described in RFC 6409.
  • Port 465: URL Rendezvous Directory for SSM (entirely unrelated to email)

Historically, port 465 was initially planned for the SMTPS encryption and authentication “wrapper” over SMTP, but it was quickly deprecated (within months, and over 15 years ago) in favor of STARTTLS over SMTP (RFC 3207). Despite that fact, there are probably many servers that support the deprecated protocol wrapper, primarily to support older clients that implemented SMTPS. Unless you need to support such older clients, SMTPS and its use on port 465 should remain nothing more than an historical footnote.

The hopelessly confusing and imprecise term, SSL, has often been used to indicate the SMTPS wrapper and TLS to indicate the STARTTLS protocol extension.

For completeness: Port 25

  • Port 25: Simple Mail Transfer (SMTP-MTA), a service that accepts submission of email from other servers (MTAs or MSAs). Described in RFC 5321.

Sources:

Gemina answered 12/11, 2013 at 23:33 Comment(9)
nice technical explanation, was looking for SSL vs TLS.Fugleman
SMTPS and its use on port 465 should remain nothing more than an historical footnote. Except that Gmail and most other email providers use Port 465 for SSL aka SMTPS. It is a reality that's not going anywhere, no matter what IANA specifies.Mccullers
@EricJ. ...But gmail also supports port 587. Do you know which port Google uses internally? Otherwise, the fact that they support 465 doesn't really count as evidence it's preferred or even particularly commonly used.Disquietude
Well, we are at 2018 and i see no port becoming history. 456 still being used by big players. Also, i would edit my answer to reflect that IANA is a mess, and they still dont agree if they should use 456 or not - RFC 8314 tools.ietf.org/html/rfc8314#page-6 - When a TCP connection is established for the "submissions" service (default port 465), a TLS handshake begins immediately - This RFC is referenced by your "Port 456" link :) - registration date: 2017-12-12Debatable
"Rendezvous" spelling has now been corrected at iana.orgJonson
This should be updated to reflect that IANA now has port 465 assigned to both urd and submissions and that RFC8314 recommends implicit TLS / port 465 for message submission.Tenebrific
Thank you very much, I had to fallback using 465 due to a issue with my TLS on 587. This just confirmed that I should focus on making 587 work.Sandrocottus
Have you noticed RFC 8314 already? See here: tools.ietf.org/html/rfc8314 - basically, 587 is going to be deprecated and port 465 will be used for SMTP over TLS. Note that this new RFC updates RFC 6409 which you answer is based on.Applicator
Also note that port 465 has been registered with IANA for SMTP over TLS in addition to Cisco SSM: iana.org/assignments/service-names-port-numbers/…Applicator
D
38

The correct answer to this question has been changed by the publication of RFC 8314. As a result, port 465 and 587 are both valid ports for a mail submission agent (MSA). Port 465 requires negotiation of TLS/SSL at connection setup and port 587 uses STARTTLS if one chooses to negotiate TLS. The IANA registry was updated to allow legitimate use of port 465 for this purpose. For mail relay, only port 25 is used so STARTTLS is the only way to do TLS with mail relay. It's helpful to think of mail relay and mail submission as two very different services (with many behavior differences like requiring auth, different timeouts, different message modification rules, etc.) that happen to use a similar wire protocol.

Dehypnotize answered 27/9, 2018 at 23:25 Comment(3)
Is it better to use port 465 or 587?Bartlett
If you are running a public SMTP service: both for compatibility. If it is private, prefer Implicit TLS on 465 unless you must support clients that do not support it. Supporting excerpt: "However, to maximize the use of encryption for submission, it is desirable to support both mechanisms for Message Submission over TLS for a transition period of several years. As a result, clients and servers SHOULD implement both STARTTLS on port 587 and Implicit TLS on port 465 for this transition period" tools.ietf.org/html/rfc8314#section-3.3Edition
Prefer port 465 for Implicit TLS for SMTP submission, per the recommendations in RFC8314.Natalyanataniel
S
17

I use port 465 all the time.

The answer by danorton is outdated. As he and Wikipedia say, port 465 was initially planned for the SMTPS encryption and quickly deprecated 15 years ago. But a lot of ISPs are still using port 465, especially to be in compliance with the current recommendations of RFC 8314, which encourages the use of implicit TLS instead of the use of the STARTTLS command with port 587. (See section 3.3). Using port 465 is the only way to begin an implicitly secure session with an SMTP server that is acting as a mail submission agent (MSA).

Basically, what RFC 8314 recommends is that cleartext email exchanges be abandoned and that all three common IETF mail protocols be used only in implicit TLS sessions for consistency when possible. The recommended secure ports, then, are 465, 993, and 995 for SMTPS, IMAP4S, and POP3S, respectively.

Although RFC 8314 certainly allows the continued use of explicit TLS with port 587 and the STARTTLS command, doing so opens up the mail user agent (MUA, the mail client) to a downgrade attack where a man-in-the-middle intercepts the STARTTLS request to upgrade to TLS security but denies it, thus forcing the session to remain in cleartext.

Showbread answered 8/9, 2015 at 14:44 Comment(6)
He is correct. Just because ISPs abuse it and haven't updated their documentation does not make it incorrect. He didn't say it isn't used - just that it is not a practice that follows the RFCs. In other words, you should be using 25 and 587 with email, and only use 465 if you HAVE to, for some reason.Sleepwalk
PREFER port 465 over port 587, as 465 is used for Implicit TLS for SMTP submission, which follows the recommendations in RFC8314. It recommends that "connections to Mail Submission Servers and Mail Access Servers be made using "Implicit TLS" (as defined below), in preference to connecting to the "cleartext" port and negotiating TLS using the STARTTLS command or a similar command."Natalyanataniel
@Sleepwalk Section 3.3 of the RFC is pretty clear: rfc-editor.org/rfc/rfc8314#section-3.3 The RFC says "it is desirable to migrate core protocols ... to implicit TLS over time." So it is most certainly a "practice that follows the RFCs" to use port 465.Steger
This is not entirely accurate. Yes, the move to TLS is recommended. That is orthogonal to the recommended port usage. Port 465, specifically, is not recommended, because IANA has reassigned the port, as mentioned in another comment here and in the RFC itself, which has a section discussing this problem, specifically (7.3 and other parts). 587 and STARTTLS are the preferred modern mechanisms. 465 is, essentially, legacy, and shouldn't be used for new deployments.Sleepwalk
Read the RFC again. It specifically talks about migrating to 465.Perpetual
@dodexahedron, please stop repeating the same nonsense again and again. Port 465 for STMP use is not deprecated! In fact it's quite the opposite - 465 is now the preferred port for SMTP over TLS, and 587 is going to be phased out (it's not yet deprecated). Port 587 is used for cleartext (unencrypted) SMTP, which may be upgraded via STARTTLS, but it also may just as well not be upgraded. (Especially if your ISP or other man-in-the-middle strips the advertised STARTTLS extension out of the SMTP handshake.) The long term goal is to always use TLS unconditionally, and that's what 465 is for.Regardless
H
8

I don't want to name names, but someone appears to be completely wrong. The referenced standards body stated the following: submissions 465 tcp Message Submission over TLS protocol [IESG] [IETF_Chair] 2017-12-12 [RFC8314]

If you are so inclined, you may wish to read the referenced RFC.

This seems to clearly imply that port 465 is the best way to force encrypted communication and be sure that it is in place. Port 587 offers no such guarantee.

Hardily answered 18/9, 2018 at 18:37 Comment(2)
Why is it better to use port 465?Bartlett
"When a TCP connection is established ... [to] port 465, a TLS handshake begins immediately." This model is "inherently simpler to implement, debug, and deploy." Connections to port 587 are made in "cleartext" and TLS is negotiated afterward using the STARTTLS command. "Although there's nothing inherently wrong with [it], the fact that it resulted in a common implementation error (made independently by multiple implementers) suggests that it is a less secure architecture than Implicit TLS." See RFC8314 Appendix A for discussion.Natalyanataniel
S
5

Port 465: IANA has reassigned a new service to this port, and it should no longer be used for SMTP communications.

However, because it was once recognized by IANA as valid, there may be legacy systems that are only capable of using this connection method. Typically, you will use this port only if your application demands it. A quick Google search, and you'll find many consumer ISP articles that suggest port 465 as the recommended setup. Hopefully this ends soon! It is not RFC compliant.

Port 587: This is the default mail submission port. When a mail client or server is submitting an email to be routed by a proper mail server, it should always use this port.

Everyone should consider using this port as default, unless you're explicitly blocked by your upstream network or hosting provider. This port, coupled with TLS encryption, will ensure that email is submitted securely and following the guidelines set out by the IETF.

Port 25: This port continues to be used primarily for SMTP relaying. SMTP relaying is the transmittal of email from email server to email server.

In most cases, modern SMTP clients (Outlook, Mail, Thunderbird, etc) shouldn't use this port. It is traditionally blocked, by residential ISPs and Cloud Hosting Providers, to curb the amount of spam that is relayed from compromised computers or servers. Unless you're specifically managing a mail server, you should have no traffic traversing this port on your computer or server.

Saltigrade answered 11/4, 2018 at 9:33 Comment(1)
This answer is now incorrect, port 465 for Implicit TLS for SMTP submission is preferred, per the recommendations in RFC8314. See my above comment.Natalyanataniel

© 2022 - 2024 — McMap. All rights reserved.