
Understanding SMTP: The Backbone of Email Delivery #
Simple Mail Transfer Protocol (SMTP) is the fundamental Internet standard used for sending emails across networks. The original specifications for this protocol were published under RFC 821 in 1982. Later, the Internet Engineering Task Force introduced updated specifications under RFC 5321.
By default, the protocol establishes connections over TCP. However, modern security requirements have drastically changed how network ports are utilized.
Modern SMTP Ports and Security Standards #
Network security standards have evolved significantly over the decades. Consequently, choosing the correct port is vital for modern email delivery.
- Port 25: This remains the standard port for server-to-server relaying. However, most residential ISPs block it to prevent massive spam outbreaks.
- Port 587: This is the modern standard for email submission. It utilizes explicit TLS encryption via the STARTTLS command.
- Port 465: Originally scheduled for deprecation, this port is now officially reinstated for implicit TLS connections. It offers secure connection wrappers from the very start of the session.
Core SMTP Commands #
When you send an email, your application transmits specific text commands to the mail server. Modern servers support these basic and extended commands:
- EHLO / HELO: Identifies your domain name to the server. Modern systems prefer EHLO to activate Extended SMTP features.
- MAIL FROM: Specifies the sender’s email address to start a new transaction.
- RCPT TO: Identifies the immediate recipient. You can repeat this command for multiple addresses.
- DATA: Signals that the message body text follows. You must end the stream with a single period on its own line.
- RSET: Aborts the current email transaction immediately without closing the connection.
- VRFY: Verifies whether a specific mailbox exists on the server. Most modern servers disable this to prevent spam mining.
- QUIT: Terminates the session and closes the connection to the remote server.
Note on Deprecated Commands: Legacy commands like EXPN, SEND, SAML, SOML, and TURN are rarely used today. Modern security protocols have largely replaced them with secure relay configurations.
Standard SMTP Server Replies #
Every command you send receives a three-digit numerical reply code from the mail server. The first digit reveals the general status of your request.
Success and Progress Codes (2xx & 3xx) #
- 220: The server is ready and waiting for your input.
- 250: The requested action completed successfully.
- 354: Start your message text input. The server is ready to receive your data payload.
Temporary Failure Codes (4xx) #
- 421: The service is temporarily unavailable. Try your transmission again later.
- 450: The recipient’s mailbox is busy or temporarily locked.
- 451: The action aborted due to a local server error.
- 452: The server rejected the message because it ran out of system storage space.
Permanent Error Codes (5xx) #
- 500: Syntax error detected because the command line was too long.
- 501: Parameter syntax error found within the arguments.
- 503: Bad sequence of commands. For example, you sent data before defining a recipient.
- 550: Mailbox not found or rejected due to strict spam policy reasons.
- 552: The transaction failed because the recipient’s mailbox is completely full.
A Typical SMTP Conversation Exchange #
When a client connects to a mail server, the actual text conversation follows this precise structure. Server responses appear in bold text for clarity.
220 mx1.example.com ESMTP Postfix
EHLO example.com
250-mx1.example.com greeting okay
250-STARTTLS
250 8BITMIME
MAIL FROM:<example@example.com>
250 2.1.0 Ok
RCPT TO:<example2@example.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Modern SMTP Test
This is a secure test message.
.
250 2.0.0 Ok: queued as 4227FE00C
QUIT
221 2.0.0 Bye
RFC Reference Links #
To explore the technical specifications deeply, review the official documentation:
- RFC 821 (Legacy Standard): https://tools.ietf.org/html/rfc821
- RFC 5321 (Current Standard): https://tools.ietf.org/html/rfc5321
