ChatGPT解决这个技术问题 Extra ChatGPT

What is the difference between ports 465 and 587?

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

The only difference is formalized standards and 465 port is for legacy support?
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.

A
AnFi

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.


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.
@Ilia standard SMTP port of normal MTA can not reject (all) unauthenticated SMTP connections.
How about Postfix? It doesn't let relaying mail by default but only for connections from same network?
@Ilia There is also incoming mail to local email domains.
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.
C
Community

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:

IANA Service Name and Transport Protocol Port Number Registry

“Revoking the smtps TCP port” - Email from Internet Mail Consortium director Paul Hoffman, 12 Nov 1998.

RFC 6409 - Message Submission for Mail

RFC 5321 - Simple Mail Transfer Protocol

RFC 3207 - SMTP Service Extension for Secure SMTP over Transport Layer Security

RFC 4607 - Source-Specific Multicast for IP


nice technical explanation, was looking for SSL vs TLS.
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.
@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.
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-12
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.
C
Community

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.


Is it better to use port 465 or 587?
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.3
Prefer port 465 for Implicit TLS for SMTP submission, per the recommendations in RFC8314.
C
Community

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.


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.
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."
B
BlackBeard

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.


This answer is now incorrect, port 465 for Implicit TLS for SMTP submission is preferred, per the recommendations in RFC8314. See my above comment.
H
Hedam

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.


Why is it better to use port 465?
"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.