How SMTP (Simple Mail Transfer Protocol) works and are all the ports still relevant?
SMTP (Simple Mail Transfer Protocol) is the standard protocol used for sending email messages across the internet. Here’s a simplified overview of how SMTP works:
-
Sender’s Mail Client: The process begins when a user composes an email using their email client (like Outlook, Thunderbird, Gmail web interface, etc.).
-
Sender’s SMTP Server: Once the user hits "Send", the email client communicates with the sender's SMTP server (outgoing mail server). The SMTP server handles the outgoing message, preparing it for transmission.
-
Domain Name Resolution: Before sending the email, the sender’s SMTP server needs to find the recipient’s SMTP server. This involves DNS (Domain Name System) lookup to resolve the recipient's email domain to its associated mail exchange (MX) server.
-
Connecting to Recipient’s SMTP Server: Once the recipient’s SMTP server is identified, the sender’s SMTP server establishes a connection to it. This connection typically occurs on port 25, 587, or 465 (as discussed later).
-
SMTP Handshake: The sender’s SMTP server initiates a conversation (handshake) with the recipient’s SMTP server. This involves sending commands and responses to verify readiness and capabilities for message transmission.
-
Sending the Email: Once the handshake is successful, the sender’s SMTP server transfers the email message to the recipient’s SMTP server. This includes the sender's email address, recipient's email address, subject, and the message content.
-
Recipient’s Mail Server: The recipient’s SMTP server then accepts the incoming email message and stores it temporarily.
-
Recipient’s Mailbox: Finally, when the recipient checks their email (via webmail, email client, or mobile device), their email client connects to their POP3 or IMAP server to download the message into their inbox.
SMTP is a text-based protocol that uses a set of commands and responses between servers to ensure reliable email transmission. It operates in a store-and-forward manner, meaning email servers store messages temporarily until they can deliver them to the recipient’s mailbox.
Throughout the process, security measures like authentication and encryption (using TLS/SSL) can be implemented to protect the confidentiality and integrity of email communications.
SMTP (Simple Mail Transfer Protocol) typically uses the following ports:
-
Port 25: This is the default port for SMTP. It is used for communication between mail servers. However, many ISPs and cloud providers block or restrict traffic on this port due to its historical use by spammers.
-
Port 587: This port is the recommended port for sending email using SMTP (submission port). It is specifically designated for email client to mail server communication, typically requiring authentication and supporting encryption (TLS/SSL).
-
Port 465: Historically, this port was used for SMTP over SSL/TLS (SMTPS). However, its use is now deprecated in favor of using port 587 with STARTTLS for secure communication.
In summary:
- Port 25: Default SMTP port for mail server to mail server communication.
- Port 587: Recommended submission port for email clients to send mail to mail servers securely with authentication.
- Port 465: Deprecated port for SMTP over SSL/TLS; use of port 587 with STARTTLS is encouraged instead.
When configuring email clients or servers, ensure you select the appropriate port based on the security and authentication requirements of your setup.