Learn which SMTP ports to use for email delivery: 25, 465, 587, or 2525. Our guide helps you choose the right port for security and deliverability.
Every day, over 370 billion emails are sent across the internet, but only a small percentage of users understand the infrastructure that makes this possible.
At the core of this massive global communication system lies the Simple Mail Transfer Protocol (SMTP) – the standard that governs how emails are transmitted from sender to recipient.
This system has numerous factors and components at play, one of which is the SMTP port—a critical element that affects email security, deliverability, and performance.
Whether you're an IT administrator configuring an email server, a developer integrating email functionality into an application, or simply a curious user setting up an email client, understanding SMTP ports can mean the difference between secure, reliable email delivery and messages that never reach their destination.
To help you understand and make the best decisions, we took the time to write this comprehensive guide, specifically focused on ports 25, 465, 587, and 2525. Don’t worry if you don’t know why these are important - we’ll talk about it, as well as;
- How SMTP works and why ports matter
- The evolution of email transmission security
- Detailed analysis of each port's security features (and why you’d choose each one)
- Practical guidance on which port to choose for your specific needs
- Common issues and troubleshooting solutions
Let’s dive in.
Here's a concise SMTP port reference guide:
✔ Port 25: Standard SMTP port for server-to-server email relay (commonly blocked due to spam issues).
✔ Port 587: Default secure port for email submission (recommended).
✔ Port 465: Legacy SMTPS port (to be used only if necessary).
✔ Port 2525: Alternative port when other ports are blocked.
Understanding SMTP Fundamentals
What is SMTP and How Does It Work?
Simple Mail Transfer Protocol (SMTP) is the Internet standard for electronic mail transmission.
Developed in the early 1980s, SMTP serves as the foundation for how emails move across networks from sender to recipient.
Think of the functions of SMTP a bit like a relay race:
- Composition: You write an email in your client (like Gmail, Outlook, or Apple Mail)
- Submission: Your email client submits the message to an SMTP server
- Relay: The SMTP server determines where to send the message next
- Delivery: After potentially passing through several SMTP servers, the message arrives at the recipient's mail server
- Retrieval: The recipient accesses the message using protocols like POP3 or IMAP
Alt: An illustration that shows the simple process of how an email is sent across the internet (Compose > SMTP Server > Deliver to Recipient’s Mail Server, and then Read)
To visualize this process, imagine sending a physical letter:
- You (email client) write a letter and drop it in a mailbox (SMTP submission)
- The postal service (SMTP relay) routes your letter through various sorting facilities
- Eventually, the letter arrives at your recipient's local post office (incoming mail server)
- Your recipient checks their mailbox (POP3/IMAP) and retrieves your letter
The Evolution of SMTP Security
When SMTP was first standardized in 1982, email security wasn't a primary concern.
The internet was a much smaller, more trusted network primarily used by academic and research institutions.
Therefore, the original SMTP specification had no built-in security mechanisms – emails were transmitted as plain text, with no encryption or robust authentication.
However, this lack of security became problematic as the internet grew and email became a critical communication tool for businesses and individuals.
Some key security issues with traditional SMTP include:
- Plain text transmission: Messages could be intercepted and read
- No encryption: Sensitive data was vulnerable
- Limited authentication: Easy to forge sender identities
- Open relay potential: Servers could be exploited to send spam
Over time, extensions and enhancements to SMTP were developed to address these shortcomings:
- SMTP AUTH: Provided authentication mechanisms
- STARTTLS: Added support for transport-level encryption
- SMTPS: Implemented SSL/TLS encryption throughout the connection
What are Ports and Why Do They Matter?
Alt: An illustration of icons representing the different email ports and why you’d use them
In networking, a port is a logical endpoint for communication.
Think of ports as specialized doorways into a computer system – each serving a specific type of traffic. Ports are identified by numbers ranging from 0 to 65535.
For SMTP communication, specific ports have been designated:
- Port 25: The original SMTP port
- Port 465: Initially designated for SMTPS (SMTP over SSL)
- Port 587: The modern message submission port
- Port 2525: An alternative port used when standard ports are blocked
The choice of port affects:
- Security: Different ports offer varying levels of encryption and authentication
- Deliverability: ISPs may block certain ports to reduce spam
- Compatibility: Not all email services support all ports
- Functionality: Some ports are designed for specific purposes in the email ecosystem
Understanding these distinctions is crucial for setting up reliable, secure email systems.
The Major SMTP Ports: A Historical Perspective
So, why these ports and why are there differences? Why not just have one secure port specifically for email that everyone uses? Let’s break that down.
Port 25: The Original Standard
Port 25 was established as the standard SMTP port in 1982 when the protocol was first defined by the Internet Engineering Task Force (IETF).
For many years, it served as the default port for all SMTP traffic, both for submitting emails from clients to servers and for server-to-server relay.
The implementation of Port 25 originated from a 1982 request by the University of Southern California to the Internet Engineering Task Force (IETF).
At that time, the focus was on establishing a standardized communication channel for email transmission with basic protection against attacks, such as man-in-the-middle interception.
Today, the role of Port 25 has narrowed significantly. Its primary function is now limited to:
- Server-to-server communication: Mail Transfer Agents (MTAs) use Port 25 to relay messages between mail servers
- Legacy system support: Some older email systems still rely on Port 25
A simple telnet connection to an SMTP server on Port 25 might look like this:
> telnet smtp.example.com 25Trying 192.0.2.1...
Connected to smtp.example.com.
Escape character is '^]'.
220 smtp.example.com ESMTP Postfix
> EHLO client.example.com
250-smtp.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
Notice the 250-STARTTLS line, indicating that this server supports encryption via the STARTTLS command, but it's not mandatory.
However, with this in mind, Port 25 has several significant security limitations:
- No required encryption: By default, communications over Port 25 are unencrypted
- Optional STARTTLS: While supported, encryption isn't mandatory
- Vulnerable to interception: Plain text communications can be easily read if intercepted
- Spam vector: Historically used for sending spam emails
Because of these issues, particularly its exploitation by spammers, many Internet Service Providers (ISPs) and cloud hosting providers now block outbound traffic on Port 25 from their customers.
This blocking helps prevent compromised systems from being used to distribute spam.
If you're experiencing connection issues on Port 25, it's likely because your ISP is blocking it. In a simple test, you might see:
> telnet smtp.example.com 25Trying 192.0.2.1...
telnet: Unable to connect to remote host: Connection timed out
This blocking is so widespread that Port 25 should no longer be used for email client submissions. Instead, it should be reserved solely for server-to-server communication.
Port 465: The SSL/TLS Implicit Encryption Port
Port 465 has perhaps the most convoluted history of the SMTP ports.
In the mid-1990s, as the need for email encryption became apparent, the Internet Assigned Numbers Authority (IANA) briefly assigned Port 465 for "SMTPS" – SMTP over SSL.
However, this assignment was short-lived.
Around 1997, the IETF decided on a different approach to secure SMTP: adding the STARTTLS command to the SMTP protocol itself, which would allow encryption to be negotiated over existing ports.
As a result, Port 465's official assignment for SMTPS was revoked after only about a year.
Despite this official deprecation, many email services had already implemented support for Port 465, and it continued to be widely used. This created a situation where Port 465 was being used in practice even though it was no longer officially designated for SMTP.
Implicit TLS Functionality
Port 465 uses what's known as "Implicit TLS" or "Implicit SSL":
- The connection begins with SSL/TLS negotiation immediately
- No part of the communication occurs in plain text
- If TLS negotiation fails, the connection is terminated
- All subsequent SMTP commands are sent through the encrypted channel
This approach is similar to how HTTPS works on the web – the secure connection is established before any application data is transmitted.
Here's a simplified communication flow for Port 465:
- Client initiates connection to server on Port 465
- SSL/TLS handshake occurs
- Upon successful handshake, SMTP communication begins
- All SMTP commands and data are encrypted
Today, Port 465 exists in a curious state:
- It's not officially recognized by the IETF for SMTP
- It's widely supported by email service providers
- It's recommended by some consumer email providers
- It provides strong security through its implicit TLS approach
Port 465 is appropriate for:
- Legacy systems that were configured to use SMTPS on this port
- Scenarios where maximum protection against downgrade attacks is required
- Situations where an email provider specifically recommends it
The Internet Assigned Numbers Authority has now reassigned Port 465 to a different service ("URL Rendezvous Directory for SSM"), though in practice it continues to be primarily used for secure SMTP.
Port 587: The Modern Submission Port
In 1998, RFC 2476 (later replaced by RFC 6409) introduced the concept of a dedicated "message submission" port separate from the SMTP relay port. This separation addressed the growing need to distinguish between two different types of SMTP traffic:
- Message submission: Email clients submitting messages to their mail server
- Message relay: Mail servers transferring messages to other mail servers
Port 587 was designated for this message submission role, creating a clear distinction from Port 25's relay function. This separation allowed for different policies and security requirements to be applied to each type of traffic.
STARTTLS Capabilities
Port 587 uses "Explicit TLS" through the STARTTLS command. Here's how it works:
- Client connects to the server on Port 587
- Server identifies itself and lists its supported extensions
- Client issues the STARTTLS command
- Server responds, and TLS negotiation begins
- Upon successful negotiation, the SMTP session is encrypted
- Client typically authenticates using SMTP AUTH
- Email submission proceeds within the encrypted channel
A typical SMTP session using Port 587 with STARTTLS might look like this:
> telnet smtp.example.com 587Trying 192.0.2.1...
Connected to smtp.example.com.
Escape character is '^]'.
220 smtp.example.com ESMTP Postfix
> EHLO client.example.com
250-smtp.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
> STARTTLS
220 2.0.0 Ready to start TLS
... (TLS negotiation occurs) ...
> EHLO client.example.com
250-smtp.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
> AUTH LOGIN
334 VXNlcm5hbWU6
dXNlcm5hbWU=
334 UGFzc3dvcmQ6
cGFzc3dvcmQ=
235 2.7.0 Authentication successful
Notice how SMTP communication begins in plain text but switches to TLS encryption after the STARTTLS command is issued.
In most cases, Port 587 will be your port of choice.
It’s emerged as the recommended standard for email submission for several compelling reasons:
- Official standard: It's recognized by the IETF as the proper port for message submission
- Wide support: Most modern email providers support Port 587
- ISP compatibility: It's less likely to be blocked by ISPs than Port 25
- Security with flexibility: Supports strong encryption while maintaining backward compatibility
- Required authentication: Typically enforces SMTP AUTH, reducing spam
For the vast majority of users and organizations setting up new email systems, Port 587 should be the default choice for message submission.
Port 2525: The Alternative Option
Port 2525 is not an officially designated SMTP port by either IANA or the IETF. Instead, it emerged as a practical alternative when the standard ports (25, 465, and 587) are blocked by ISPs or corporate networks.
Functionally, Port 2525 typically works identically to Port 587:
- It supports STARTTLS for encryption
- It requires authentication via SMTP AUTH
- It's used for message submission, not relay
The primary difference is simply the port number itself, which helps bypass network restrictions.
Port 2525 should be considered in these scenarios:
- When connecting from networks that block Ports 25, 465, and 587
- In corporate environments with strict firewall policies
- When using cloud providers that restrict standard email ports
- If you consistently experience connection issues with standard ports
Many email service providers, including Mailgun, SendGrid, and others, support Port 2525 specifically to provide this fallback option for their customers.
How to Make the Right Port Choice from a Security Perspective
Alt: An illustration of a developer thinking about which email port they should use in their project
Let’s talk security because, from a developer perspective, this is one of your most important considerations. There are several options.
STARTTLS (Explicit TLS)
STARTTLS, used primarily on Ports 25 and 587, provides "opportunistic encryption" through these steps:
- The connection begins unencrypted
- The client issues the STARTTLS command
- If the server supports it, encryption is negotiated
- Communication continues encrypted
Advantages:
- Backward compatibility with non-TLS servers
- Works with existing ports and infrastructure
Disadvantages:
- Initial communication is unencrypted
- Vulnerable to downgrade attacks where an attacker prevents the STARTTLS command
- Not all servers require TLS, allowing plain text fallback
Implicit TLS
Implicit TLS, used on Port 465, takes a different approach:
- The connection begins with TLS negotiation immediately
- If TLS negotiation fails, the connection is terminated
- No unencrypted communication ever occurs
Advantages:
- No plain text communication at any point
- Impossible to downgrade to unencrypted connection
- Stronger protection against man-in-the-middle attacks
Disadvantages:
- Not backward compatible with servers that don't support TLS
- Not the official IETF standard approach
Authentication Requirements
Authentication is a critical security component that verifies the identity of the sending client. The authentication requirements vary by port:
Port 25:
- Authentication often optional
- Frequently allows unauthenticated relay between servers
- May permit anonymous message submission on some servers
Port 465:
- Authentication typically required
- Usually enforced after TLS encryption established
- Rarely allows anonymous message submission
Port 587:
- Authentication required by standard
- Enforced after STARTTLS encryption
- Specifically designed for authenticated submission
Port 2525:
- Authentication requirements match Port 587
- Requires authentication for message submission
It's worth noting that modern email servers should always require authentication for message submission, regardless of port, to prevent abuse.
Feature | Port 25 | Port 465 | Port 587 | Port 2525 |
Primary Use | Server-to-server relay | Secure message submission | Message submission | Alternative submission |
Encryption Type | Optional STARTTLS | Implicit TLS | STARTTLS | STARTTLS |
Initial Connection | Unencrypted | Encrypted | Unencrypted | Unencrypted |
Downgrade Attack Risk | High | Low | Medium | Medium |
Authentication | Optional | Required | Required | Required |
ISP Blocking Likelihood | High | Medium | Low | Low |
IETF Standard | Yes (for relay) | No | Yes (for submission) | No |
Recommended For | Server-to-server only | Legacy systems | Modern clients | When others are blocked |
Best Practices for Maximum Email Security
To ensure the highest level of email security when configuring SMTP:
- Always use encryption:
- Configure your servers to require TLS for all connections
- Disable plain text authentication
- Use strong TLS versions (TLS 1.2 or higher)
- Implement strong authentication:
- Require SMTP AUTH for all message submissions
- Use secure password storage (hashing with salt)
- Consider implementing two-factor authentication for email accounts
- Stay current with certificates:
- Use trusted CA-signed certificates
- Regularly renew SSL/TLS certificates
- Monitor for certificate vulnerabilities
- Configure proper headers and policies:
- Implement SPF, DKIM, and DMARC for authentication
- Set appropriate HSTS headers
- Configure mail servers to reject unencrypted connections
- Monitor and audit:
- Log all SMTP transactions
- Regularly review logs for suspicious activity
- Test your email security configuration periodically
A Practical Implementation Guide of SMTP Ports
Alt: An illustration of a developer thinking about the best way to set up their email sending SMTP ports
Now, choosing the ports that are best for your project. We can break down this down by use case so you can find the best fit.
For Individual Users and Email Clients
If you're configuring an email client like Outlook, Apple Mail, or Thunderbird:
- First choice: Port 587 with STARTTLS
- Widely supported and least likely to be blocked
- Example configuration for Gmail in Outlook:
- Outgoing mail server: smtp.gmail.com
- Port: 587
- Encryption: STARTTLS
- Authentication: Yes, with username and password
- Second choice: Port 465 with SSL/TLS
- If your provider specifically recommends it
- Example configuration for Yahoo Mail:
- Outgoing mail server: smtp.mail.yahoo.com
- Port: 465
- Encryption: SSL/TLS
- Authentication: Yes, with username and password
- Last resort: Port 2525 with STARTTLS
- Only if ports 587 and 465 are blocked
- Not all providers support this port, so check documentation
For Business Applications and High-Volume Senders
For applications sending transactional or marketing emails:
Recommended: Port 587
- Best balance of deliverability and security
- Supported by all major email service providers
- Example for a Node.js application using Nodemailer:
const nodemailer = require('nodemailer');let transporter = nodemailer.createTransport({
host: 'smtp.example.com',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: 'username',
pass: 'password'
},
tls: {
// do not fail on invalid certs
rejectUnauthorized: false
}
});
Alternative: Port 465
- For providers that specifically recommend it
- Example in PHP using PHPMailer:
<?php
use PHPMailer\PHPMailer\PHPMailer;
require 'vendor/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->Username = 'username';
$mail->Password = 'password';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // SSL encryption
$mail->Port = 465;
?>
Backup option: Port 2525
- When deploying on platforms that block standard ports
- Example in Python using smtplib:
import smtplibimport ssl
from email.message import EmailMessage
msg = EmailMessage()
msg.set_content("This is a test email.")
msg['Subject'] = 'Test Email'
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
context = ssl.create_default_context()
with smtplib.SMTP('smtp.example.com', 2525) as server:
server.starttls(context=context)
server.login('username', 'password')
server.send_message(msg)
For Server-to-Server Communication
For mail server configuration handling relay traffic:
Standard: Port 25
- Used for MTA-to-MTA communication
- Should be configured with STARTTLS when possible
- Example Postfix configuration in /etc/postfix/main.cf:
# Outgoing relay settingsrelayhost = [mail.example.com]:25
smtp_tls_security_level = may
smtp_tls_note_starttls_offer = yes
Alternative if port 25 is blocked: Custom configuration
- Some providers allow relay on alternate ports
- Example:
# Using alternative port for relayrelayhost = [mail.example.com]:587
smtp_tls_security_level = encrypt
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
Configuration Examples for Common Email Servers
Postfix Configuration (Linux)
To configure Postfix to secure SMTP submission on Port 587:
- Edit /etc/postfix/master.cf:
# SMTP submission on port 587submission inet n - y - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_tls_auth_only=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
- Edit /etc/postfix/main.cf to configure TLS:
# TLS parameterssmtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level=may
smtpd_tls_protocols = !SSLv2, !SSLv3
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
- Restart Postfix:
Microsoft Exchange Server
To configure Exchange Server for secure SMTP submission:
- Open the Exchange Admin Center
- Navigate to Mail Flow > Receive Connectors
- Create or edit a connector for client submission
- Configure the connector to:
- Listen on port 587
- Require TLS encryption
- Require authentication
- Set appropriate permission groups (typically 'Exchange Users')
Testing Port Connectivity and Troubleshooting
To test connectivity to an SMTP server on a specific port, you can use simple command-line tools:
Using Telnet:# Testing port 587
telnet smtp.example.com 587
# You should see something like:
Trying 192.0.2.1...
Connected to smtp.example.com.
Escape character is '^]'.
220 smtp.example.com ESMTP ready
Using OpenSSL for TLS testing:
# Testing STARTTLS on port 587
openssl s_client -starttls smtp -crlf -connect smtp.example.com:587
# Testing implicit TLS on port 465
openssl s_client -connect smtp.example.com:465
Using a dedicated SMTP testing tool like swaks:
# Basic SMTP test with authentication
swaks --server smtp.example.com --port 587 --tls --auth-user username --auth-password password --to [email protected] --from [email protected]
Common SMTP Port Issues and Solutions
Connection Timeouts and Authentication Failures
Problem: Connection Timeouts
Symptoms:
- Unable to establish connection to SMTP server
- Client reports "connection timed out" errors
- Email sending appears to hang indefinitely
Possible causes:
- ISP or network blocking the port
- Firewall restrictions
- Server is down or unreachable
- Incorrect server address
Solutions:
- Try an alternative port (587, 465, or 2525)
- Check firewall settings and network policies
- Verify the server address is correct
- Test on a different network to isolate ISP blocking issues
- Increase connection timeout settings in your email client
Problem: Authentication Failures
Symptoms:
- Connection established but authentication fails
- Error messages like "535 Authentication failed" or "Invalid username/password"
- Unable to send mail despite successful connection
Possible causes:
- Incorrect username or password
- Authentication method mismatch
- Account restrictions or security policies
- TLS/SSL requirements not met before authentication
Solutions:
- Verify credentials are correct and up-to-date
- Check which authentication methods the server supports (PLAIN, LOGIN, CRAM-MD5)
- Ensure encryption is properly configured before authentication
- For Google and Microsoft accounts, you may need an app-specific password or to enable less secure apps
- Check for account restrictions or IP limitations
Port Blocking by ISPs and Networks
Port blocking is increasingly common, especially for Port 25:
Identifying Port Blocking
Signs you're experiencing port blocking:
- Connection timeouts consistently occur
- Other internet services work normally
- Problem persists across different email clients
- Issues occur on one network but not others
Testing for port blocking:
# Use telnet to test connectivitytelnet smtp.example.com 25
# If blocked, you'll see no response or a timeout
# If open, you'll see the server's greeting banner
Solutions for Port Blocking
- Switch to an alternative port:
- Try Port 587 for message submission
- If that fails, try Port 465
- As a last resort, try Port 2525
- Use a VPN or different network:
- Mobile networks may have different policies than home ISPs
- Corporate networks may route through a smart host
- Contact your ISP:
- Some ISPs will unblock Port 25 for business customers
- Be prepared to explain your legitimate need
- Use a smart host or relay:
- Configure your mail server to relay through your ISP's SMTP server
- Use a third-party email delivery service
TLS Negotiation Issues
TLS problems can be subtle and difficult to troubleshoot:
Common TLS Issues
- Certificate validation failures:
- Server certificate is expired
- Certificate is not from a trusted authority
- Certificate hostname doesn't match the server name
- Client and server cannot agree on cipher suites
- Protocol version mismatches:
- Client using newer TLS version than server supports
- Server requiring newer TLS version than client supports
- Outdated TLS implementations with vulnerabilities
Diagnosing TLS Problems
Use OpenSSL to inspect the TLS handshake:
# For port 587 with STARTTLSopenssl s_client -starttls smtp -connect smtp.example.com:587 -tls1_2
# For port 465 with implicit TLS
openssl s_client -connect smtp.example.com:465 -tls1_2
# Look for these in the output:
# - Certificate information and expiration
# - Certificate chain validation
# - TLS version and cipher used
Solving TLS Problems
- Server-side solutions:
- Update SSL/TLS certificates
- Configure proper certificate chains
- Support modern TLS versions (1.2, 1.3)
- Disable insecure cipher suites
- Client-side solutions:
- Update email client or libraries to support modern TLS
- Configure the client to trust the server's certificate authority
- Adjust TLS security settings if needed
- Temporary workarounds (use with caution):
- Disable certificate validation for testing only
- Try different TLS versions to isolate compatibility issues
Beyond SMTP: Related Email Protocols
Alt: Someone sits at a computer with arrows pointing to icons of SMTP, IMAP, and POP3
SMTP is not the only system related to email, and it’s important to understand the rest of the system so you can build systems that work effectively, sustainably, and efficiently. Here’s a quick guide to some of the other factors you need to know.
While SMTP handles sending email, receiving email requires different protocols:
POP3 (Post Office Protocol version 3)
POP3 is one of the oldest email retrieval protocols:
- Function: Downloads messages from server to client
- Default Ports: 110 (unencrypted) and 995 (SSL/TLS)
- Behavior: Typically removes messages from server after download
- Best for: Single-device access with limited server storage
A simple POP3 session might look like:
> telnet mail.example.com 110+OK POP3 server ready
> USER username
+OK
> PASS password
+OK Logged in
> LIST
+OK 2 messages
1 1425
2 32360
> RETR 1
+OK 1425 octets
(... message content ...)
> QUIT
+OK Logging out
IMAP (Internet Message Access Protocol)
IMAP is a more sophisticated protocol for accessing mailboxes:
- Function: Synchronizes messages between server and clients
- Default Ports: 143 (unencrypted) and 993 (SSL/TLS)
- Behavior: Keeps messages on server, allowing multi-device access
- Best for: Multiple devices accessing the same mailbox
An IMAP session might begin:
> telnet mail.example.com 143* OK IMAP4rev1 Server Ready
> A001 LOGIN username password
* OK Logged in
> A002 SELECT INBOX
* 18 EXISTS
* 2 RECENT
* OK [UNSEEN 17] Message 17 is first unseen
* OK [UIDVALIDITY 1428913542] UIDs valid
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Limited
A002 OK [READ-WRITE] SELECT completed
How These Protocols Interact with SMTP
Email's end-to-end journey involves multiple protocols working together:
- Composition & Sending (SMTP):
- User writes an email
- Email client sends via SMTP to the submission server
- Message is relayed via SMTP to the recipient's mail server
- Storage & Retrieval (POP3/IMAP):
- Recipient's server stores the incoming message
- Recipient connects using POP3 or IMAP to access their mailbox
- Messages are downloaded (POP3) or synchronized (IMAP)
- Response (SMTP again):
- Recipient replies to the message
- Their client sends the reply via SMTP
- The cycle continues
Port Configurations for a Complete Email System
A comprehensive email server setup requires multiple ports:
Service | Protocol | Unencrypted Port | Encrypted Port | Encryption Method |
Sending Mail | SMTP (relay) | 25 | 25 | STARTTLS |
Mail Submission | SMTP | 587 | 587 | STARTTLS |
Secure Submission | SMTPS | N/A | 465 | Implicit TLS |
Mail Retrieval | POP3 | 110 | 995 | Implicit TLS |
Mail Access | IMAP | 143 | 993 | Implicit TLS |
Setting up a complete email server requires configuring all these ports appropriately for both sending and receiving functionality.
Future Trends and Considerations of SMTP Ports and Email Security
Alt: An illustration of a developer thinking about the future email trends
As technology evolves, so will the systems behind email. Keeping up with these is vital to ensuring your email systems work effectively, both technically and with modern regulations.
Since it’s always changing, you’ll need to stay informed and keep your finger on the pulse. Some of the best resources include:
- IETF (Internet Engineering Task Force) - Follow email-related RFCs and working groups
- M3AAWG - Messaging security and anti-abuse best practices
- US-CERT Security Bulletins - Email infrastructure security alerts
- Word to the Wise - Laura Atkins' authoritative blog on email delivery
- Postmark's Deliverability Guide - Technical deep dives on email infrastructure
- Email on Acid Blog - Technical insights on email rendering and deliverability
- Email Geeks Slack Community - Active discussions via a Slack community among email professionals
- r/emailmarketing - Reddit community for email technology discussions
- MXToolbox - Comprehensive email diagnostics and monitoring
- CheckTLS - Test SMTP TLS capabilities and security
- DMARC Analyzer - Authentication monitoring and reporting
However, as a guideline of changes to look out for, you’ll want to consider:
Emerging Standards and Security Improvements
The email landscape continues to evolve with several promising developments:
MTA-STS (SMTP Strict Transport Security)
MTA-STS is a relatively new standard (defined in RFC 8461) that helps secure email delivery:
- Allows domain owners to specify requirements for TLS encryption
- Clients can discover these policies via DNS and HTTPS
- Provides protection against downgrade and man-in-the-middle attacks
- Improves security of SMTP connections between servers
Implementation example - publishing an MTA-STS policy:
Create a DNS record:
_mta-sts.example.com. IN TXT "v=STSv1; id=20200501;"Host a policy file at https://mta-sts.example.com/.well-known/mta-sts.txt:
version: STSv1
mode: enforce
mx: mail1.example.com
mx: mail2.example.com
max_age: 86400
DANE (DNS-Based Authentication of Named Entities)
DANE (specified in RFC 7672) provides another layer of security:
- Uses DNSSEC to associate SMTP servers with their TLS certificates
- Prevents certificate spoofing attacks
- Reduces reliance on third-party certificate authorities
- Adds stronger validation for SMTP connections
DANE record example:
TLS 1.3 and Beyond
TLS itself continues to improve:
- TLS 1.3 (the latest version) provides:
- Faster connection establishment
- Improved security by removing vulnerable features
- Forward secrecy for all connections
- Simplified cipher suite negotiation
- Future TLS improvements will likely focus on:
- Quantum-resistant cryptography
- Further performance optimizations
- More robust authentication mechanisms
Best Practices for Staying Current
To maintain email security over time:
- Regular updates:
- Keep mail server software updated
- Update TLS libraries and certificates
- Review and refresh security policies periodically
- Monitor security announcements:
- Subscribe to security bulletins for your email software
- Follow organizations like US-CERT and the IETF
- Participate in email operator communities
- Implement emerging standards:
- Add MTA-STS when your mail software supports it
- Consider DANE for additional security
- Deploy DMARC, SPF, and DKIM for authentication
- Testing and validation:
- Regularly test your email infrastructure security
- Use tools like SSL Labs or CheckTLS
- Conduct periodic security audits
What to Expect in Email Transmission Security
Looking ahead, several trends are likely to shape email security:
- Greater emphasis on encryption:
- Plain text email transmission will become increasingly rare
- More providers will require TLS for all connections
- Port 25 may eventually be used exclusively with encryption
- Standardization consolidation:
- Port usage may simplify over time
- New standards will emerge to address the remaining vulnerabilities
- Implementation of security measures will become more consistent
- Enhanced authentication:
- Multi-factor authentication will become more common
- Improved methods to validate sending servers
- Better defenses against spoofing and phishing
- Integration with modern architectures:
- APIs will increasingly complement traditional SMTP
- Microservices-based email architectures will grow
- Cloud-native email solutions will expand
Wrapping up
After exploring the complexities of SMTP ports, several clear guidelines emerge:
- Port 587 remains the recommended standard for email submission:
- It provides secure transmission through STARTTLS
- It's widely supported and less frequently blocked
- It follows established IETF standards
- Port 25 should be reserved solely for server-to-server communication:
- It's frequently blocked for client connections
- It lacks mandatory security in many implementations
- It's the standard port for mail transfer between servers
- Port 465 serves as an alternative for secure submission:
- It offers implicit TLS that prevents downgrade attacks
- It may be required for legacy systems
- It provides good security but isn't the IETF standard
- Port 2525 works as a fallback option:
- It bypasses common port blocks
- It isn't standardized but is widely supported
- It should only be used when standard ports are unavailable
For different email users, our port recommendations are:
For individual users:
- Configure email clients to use Port 587 with STARTTLS
- Ensure proper authentication is enabled
- Use Port 465 only if specifically recommended by your email provider
For business email administrators:
- Configure mail servers to accept submissions on Port 587
- Require TLS encryption and authentication
- Use Port 25 only for server-to-server relay with TLS enabled
- Keep all security measures and certificates up to date
For developers integrating email functionality:
- Implement Port 587 as your default SMTP port
- Include fallback options to other ports (465, 2525)
- Always use authentication and encryption
- Stay current with security best practices
For email service providers:
- Support both Ports 587 and 465 for maximum compatibility
- Offer Port 2525 as a fallback option
- Implement strong security on all ports
- Stay ahead of emerging standards and security practices
By following these best practices and staying informed, you can ensure that your email infrastructure remains both secure and reliable, delivering messages successfully while protecting sensitive information from interception or compromise.
Email remains one of our most critical communication tools, and understanding the nuances of SMTP ports is essential for anyone managing email systems.
The protocols and ports we've explored represent decades of evolution in internet standards, adapting to growing security threats while maintaining the interoperability that makes email so universal.