Interactive Learning

Understanding SMTP

Learn how email works behind the scenes. Watch the flow, explore each command, and practice in a realistic simulated terminal.

Visual Flow

Watch emails travel from sender to recipient in real time

Command Reference

Learn each SMTP command with examples and explanations

Live Terminal

Practice typing real SMTP commands in a simulated telnet session

Email Flow

How an email travels from the sender to the recipient through SMTP servers

Senderalice@example.com
SMTP Serversmtp.example.com
Recipientbob@domain.com
Composing
Transmitting
Delivering

SMTP Commands

Click each command to see its syntax, example, and a detailed explanation

1
EHLO / HELO

Identify yourself to the server

Client →
C:EHLO client.example.com
S:250-smtp.example.com Hello client.example.com

The client initiates the conversation by identifying itself. EHLO (Extended HELO) is the modern version that also queries the server for supported extensions like STARTTLS, AUTH, and 8BITMIME. HELO is the legacy version that only identifies the client.

2
MAIL FROM

Specify the sender address

Client →
3
RCPT TO

Specify the recipient address

Client →
4
DATA

Begin sending the email content

Client →
5
QUIT

End the SMTP session

Client →
6
AUTH

Authenticate to the server

Client →
7
STARTTLS

Upgrade to encrypted connection

Client →
8
RSET

Reset the current transaction

Client →

SMTP Status Codes

Every SMTP response includes a 3-digit status code — here's what they all mean

CodeMeaningDescription
211System statusHelp message from the server
220Service readySMTP server is ready to accept connections
221Closing connectionServer is closing the transmission channel
235Auth successAuthentication completed successfully
250OKRequested action completed successfully
334Auth challengeServer challenge for authentication
354Start mail inputServer is ready to accept the email data
421Service unavailableServer is temporarily unavailable
450Mailbox unavailableRequested action not taken (mailbox busy)
452Insufficient storageServer ran out of disk space
500Syntax errorCommand unrecognized or syntax error
535Auth failedAuthentication credentials invalid
550Mailbox not foundRequested action not taken (mailbox unavailable)
552Over quotaMailbox full - exceeded storage allocation
553Invalid nameMailbox name not allowed
554Transaction failedSMTP transaction or mailing failed

Code Examples

Get started sending emails with these ready-to-use code snippets

1import smtplib
2from email.mime.text import MIMEText
3from email.mime.multipart import MIMEMultipart
4
5# Create the email message
6msg = MIMEMultipart()
7msg['From'] = 'alice@example.com'
8msg['To'] = 'bob@domain.com'
9msg['Subject'] = 'Hello from SMTP!'
10
11# Add body text
12body = "Hi Bob,\nThis email was sent via SMTP!\nBest, Alice"
13msg.attach(MIMEText(body, 'plain'))
14
15# Connect and send via SMTP
16with smtplib.SMTP('smtp.example.com', 587) as server:
17 # Upgrade to TLS encryption
18 server.starttls()
19
20 # Authenticate
21 server.login('alice@example.com', 'your-password')
22
23 # Send the email
24 server.sendmail(
25 msg['From'],
26 msg['To'],
27 msg.as_string()
28 )
29
30 print("Email sent successfully!")

Simulated Telnet Session

Type real SMTP commands in a realistic terminal — the server responds just like the real thing. Need a refresher? Check the Commands section above!

Suggested next commandView all commands
telnet smtp.example.com 587
Offline
Type 'connect' to begin an SMTP session.
C:
You Server Data
Offline

💡 This is a simulated environment — no real emails are sent. Type HELP in the terminal or check the Commands section above for a full reference.