SMTP Port Numbers Explained: 25 vs 465 vs 587 vs 2525 (Which to Use)

On this page
Use port 587 (with STARTTLS) or port 465 (with SSL/TLS) to send email from an app, website or email client. Port 25 is for mail servers talking to each other and is blocked by most home internet providers and cloud hosts. Port 2525 is an unofficial backup that many email-sending services offer when 587 is blocked.
SMTP ports at a glance
| Port | Encryption | Used for | Use it? |
|---|---|---|---|
| 25 | Optional STARTTLS | Server-to-server mail delivery (MTA to MTA) | Not from apps or PCs; usually blocked by ISPs |
| 587 | STARTTLS (upgrades a plain connection to TLS) | Message submission from email clients and apps | Yes, the standard choice |
| 465 | Implicit SSL/TLS (encrypted from the first byte) | Message submission over TLS | Yes, recommended by RFC 8314 where supported |
| 2525 | STARTTLS | Unofficial alternative submission port | Only if your provider supports it and 587 is blocked |
What is SMTP?
SMTP (Simple Mail Transfer Protocol) is the protocol for sending email. When you click Send, your email app hands the message to your provider's SMTP server (the "outgoing mail server"), which finds the recipient's mail server through its DNS MX record and delivers it there over port 25. The recipient then reads it with IMAP or POP3, which are protocols for receiving email.
Port 25 vs 587 vs 465 explained
Port 25
The original SMTP port, still used for delivery between mail servers. Because spammers abused it from infected home PCs, most ISPs and cloud platforms (AWS, Google Cloud, Azure, many VPS hosts) block outgoing port 25 by default. Don't use it to send from your app or website.
Port 587 (submission, STARTTLS)
The official port for email clients and applications to submit mail. The connection starts in plain text and is upgraded to encryption with the STARTTLS command, then you sign in. Every major provider supports it.
Port 465 (SMTPS, implicit TLS)
Originally assigned for SMTP over SSL, then withdrawn, then re-standardized in 2018 by RFC 8314 for submission with implicit TLS: the connection is encrypted before any data is sent. It is just as good as 587, and slightly safer against downgrade attacks. Choose "SSL/TLS" in your app for 465 and "STARTTLS" for 587; mixing them up is the most common cause of connection errors.
Port 2525
Not an official standard, but email services such as SendGrid, Mailgun, Brevo and SMTP2GO accept it as a fallback when a host blocks 587.
SMTP settings for popular email providers
| Provider | SMTP server | Port / encryption | Sign-in |
|---|---|---|---|
| Gmail / Google Workspace | smtp.gmail.com | 465 SSL or 587 STARTTLS | "Sign in with Google" (OAuth) or an app password with 2-Step Verification |
| Outlook.com / Hotmail | smtp-mail.outlook.com | 587 STARTTLS | Modern auth (OAuth) only |
| Microsoft 365 (work/school) | smtp.office365.com | 587 STARTTLS | OAuth recommended; Basic auth for SMTP AUTH is due to be disabled by default from the end of 2026 |
| Yahoo Mail | smtp.mail.yahoo.com | 465 SSL or 587 STARTTLS | App password |
| iCloud Mail | smtp.mail.me.com | 587 STARTTLS | App-specific password |
| Zoho Mail | smtp.zoho.com (smtp.zoho.eu etc. by region) | 465 SSL or 587 STARTTLS | Password or app password |
Full Gmail details, including sending limits, are in our Gmail IMAP, POP and SMTP settings guide. Always confirm settings in your provider's help pages, since they occasionally change.
IMAP and POP3 ports (for receiving email)
| Protocol | Encrypted (use this) | Unencrypted (avoid) |
|---|---|---|
| IMAP | 993 (SSL/TLS) | 143 |
| POP3 | 995 (SSL/TLS) | 110 |
| SMTP submission | 465 (SSL/TLS) or 587 (STARTTLS) | 25 (server relay only) |
IMAP keeps mail on the server and syncs every device; POP3 downloads it to one device. For phones and multiple computers, use IMAP.
How to send email from a website or app
- WordPress and website contact forms: use an SMTP plugin or your host's mail settings with port 587 or 465 and a dedicated mailbox or email service; PHP's built-in
mail()often lands in spam. - Transactional email services (SendGrid, Mailgun, Amazon SES, Brevo, Postmark): better delivery for receipts, password resets and newsletters; they give you an SMTP host, port 587/465/2525 and an API key as the password.
- Set up SPF, DKIM and DMARC DNS records for your domain so receiving servers trust your mail. Gmail and Yahoo require them for bulk senders.
How to test an SMTP port
- Windows (PowerShell):
Test-NetConnection smtp.gmail.com -Port 587→ "TcpTestSucceeded : True" means the port is reachable. - Mac/Linux:
nc -vz smtp.gmail.com 587 - Check STARTTLS:
openssl s_client -starttls smtp -connect smtp.gmail.com:587(for 465:openssl s_client -connect smtp.gmail.com:465).
SMTP errors and fixes
| Error | Likely cause | Fix |
|---|---|---|
| Connection timed out | Port blocked by ISP, firewall or cloud host | Switch between 587, 465 and 2525; check firewall/antivirus; ask your host to unblock |
| SSL/TLS handshake error, "wrong version number" | Encryption type doesn't match the port | 465 = SSL/TLS, 587 = STARTTLS |
| 535 Authentication failed | Wrong password, or the provider requires OAuth/app password | Create an app password or use "Sign in with" OAuth |
| 530 Must issue a STARTTLS command first | Encryption not enabled | Turn on STARTTLS/TLS in the app |
| 550 / 554 rejected, or mail goes to spam | Missing SPF/DKIM/DMARC, sending limits, or a blocklisted IP | Fix DNS records, use an email service, check sending limits |
FAQ
Is port 587 or 465 better?
Both are secure when set up correctly. RFC 8314 slightly prefers 465 (implicit TLS); 587 is the most widely supported. Use whichever your provider lists.
Is SMTP port 25 still used?
Yes, between mail servers. It just shouldn't be used to send from your computer or app.
What port does Gmail SMTP use?
smtp.gmail.com on 465 (SSL) or 587 (STARTTLS).
What is the SMTP port for SSL?
465.