Quick answer
If an app asks for an outgoing (SMTP) port, use 587 with STARTTLS, or 465 with SSL/TLS if your provider lists it. For incoming mail, use IMAP on 993. You will rarely need anything else. The provider pages for Gmail and Google Workspace and Microsoft 365 list the exact server names.
Every email port in one table
| Port | Protocol | Encryption | Used for |
|---|---|---|---|
| 25 | SMTP | STARTTLS when both servers support it | Mail servers delivering to each other |
| 587 | SMTP submission | STARTTLS | Apps and email clients sending mail (the standard) |
| 465 | SMTP submission | SSL/TLS from the start | Apps and email clients sending mail |
| 2525 | SMTP (unofficial) | Usually STARTTLS | A fallback some sending services offer |
| 993 | IMAP | SSL/TLS | Reading mail, kept in sync with the server |
| 143 | IMAP | STARTTLS | Older IMAP port |
| 995 | POP3 | SSL/TLS | Downloading mail to one device |
| 110 | POP3 | STARTTLS | Older POP3 port |
SMTP ports: 25, 587, 465 and 2525
Port 25: server to server
The original SMTP port, defined in RFC 5321. When your provider delivers an email to the recipient’s mail server, it connects on port 25. Because spam once poured out of infected home computers on this port, many internet providers and cloud hosts block outgoing connections to it. Apps should not use it.
Port 587: the standard for sending
Set aside for message submission in RFC 6409. The app connects, upgrades the connection to encrypted with STARTTLS, then signs in. Microsoft 365, Gmail and almost every provider support it.
Port 465: encrypted from the first byte
465 has a messy history: it was assigned, withdrawn, and then made official again for submission in RFC 8314 in 2018, which recommends encryption from the start. Gmail supports it; Microsoft 365 lists 587 instead.
Port 2525: an unofficial fallback
Not part of any standard, but some email sending services accept it when 587 and 465 are blocked. Mailbox providers like Gmail and Microsoft 365 do not use it.
IMAP and POP3 ports
IMAP keeps mail on the server and in sync across every device, which is what sending tools need to read replies and run warm-up. Use 993. POP3 downloads mail to one device and is rarely used now; its encrypted port is 995. The older ports 143 and 110 start unencrypted and upgrade with STARTTLS. For how the protocols differ, see what SMTP is, and SMTP vs IMAP vs POP3.
STARTTLS or SSL/TLS?
Both end with an encrypted connection. STARTTLS (ports 587, 143, 110) connects in plain text and then upgrades. SSL/TLS, also called implicit TLS (ports 465, 993, 995), is encrypted from the first byte. RFC 8314 recommends implicit TLS where possible, but both are secure when the app insists on encryption. The one thing to avoid is a setting that allows the connection to continue unencrypted.
Ports for Gmail and Microsoft 365
| Provider | SMTP | IMAP | POP3 |
|---|---|---|---|
| Gmail and Google Workspace | smtp.gmail.com, 587 or 465 | imap.gmail.com, 993 | pop.gmail.com, 995 |
| Microsoft 365 | smtp.office365.com, 587 | outlook.office365.com, 993 | outlook.office365.com, 995 |
| Outlook.com and Hotmail | smtp-mail.outlook.com, 587 | outlook.office365.com, 993 | outlook.office365.com, 995 |
Testing whether a port is blocked
If an app times out, check whether your network lets the connection through. On Mac, Linux, or Windows with OpenSSL installed, these commands open an encrypted connection and print the server’s greeting:
openssl s_client -connect smtp.gmail.com:465 -crlf -quietopenssl s_client -starttls smtp -connect smtp.office365.com:587 -crlf -quietA line starting with 220 means the port is open. If the command hangs and times out, something between you and the server is blocking it: try the other port, another network, or ask your network admin.
Frequently asked questions
What is the default SMTP port?
Port 25 is the original SMTP port and is still used between mail servers. For sending from an app or email client, the standard ports are 587 with STARTTLS and 465 with SSL/TLS.
Should I use port 587 or 465?
Use whichever your provider lists. Both are encrypted and both are standard for sending from an app. Microsoft 365 uses 587; Gmail accepts both.
What port does IMAP use?
993 with SSL/TLS. Port 143 is the older port that starts unencrypted and upgrades with STARTTLS; most providers now expect 993.
Why is port 25 blocked?
Many home internet providers and cloud hosts block outgoing port 25 to stop infected computers sending spam directly. Apps should send on 587 or 465 instead, which require signing in.
What is port 2525?
An unofficial alternative that some email sending services offer when 587 and 465 are blocked. It is not part of the standards and mail providers like Gmail and Microsoft 365 do not use it.