Configuring SMTP, IMAP and POP ports can be confusing. Users and sometimes even system administrators aren’t sure when to use port 25, 587, or 465.
This article will clarify all ports related to the mail server.
IMAP uses port 143, but SSL/TLS encrypted IMAP uses port 993.
POP uses port 110, but SSL/TLS encrypted POP uses port 995.
SMTP uses port 25, but SSL/TLS encrypted SMTP uses port 465.
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 a historical footnote.