SMTP Server Commands Explained | Full List, Syntax, and Use Cases

Explore the full list of SMTP server commands including HELO, MAIL FROM, RCPT TO, DATA, and more. Learn their syntax, usage, and how they power secure email communication.

May 24, 2025 - 13:12
Updated: 1 month ago
103.2k
SMTP Server Commands Explained | Full List, Syntax, and Use Cases

Quick answer: SMTP (Simple Mail Transfer Protocol) sends email between servers and clients, mainly over TCP port 25. The core commands are HELO or EHLO to greet, MAIL FROM, RCPT TO, DATA to send the message body, and QUIT. Security teams study them to test mail configurations and detect spoofing or relay abuse.

Key takeaways

  • EHLO, MAIL FROM, RCPT TO and DATA are the sequence for sending a message.
  • SMTP over port 25 is for server to server, and submission usually uses 587.
  • Test manually with telnet or openssl in a lab.

Table of Contents

SMTP (Simple Mail Transfer Protocol) is the backbone of sending emails over the internet. Cybersecurity professionals, network administrators and aspiring ethical hackers should understand SMTP server commands to analyse email traffic, test configurations and detect vulnerabilities like email spoofing or phishing.

This post covers what SMTP is, its working mechanism, and a full list of SMTP commands, including their syntax, functions, and examples.

What Is SMTP?

SMTP stands for Simple Mail Transfer Protocol. It's an application-layer protocol used to send and relay emails between mail servers and clients. SMTP works primarily over TCP port 25 (and sometimes 587 or 465 for secure connections).

SMTP doesn’t retrieve or store messages, it only sends them. For receiving emails, protocols like IMAP or POP3 are used.

How SMTP Communication Works

When you send an email, here's what typically happens:

  1. Your email client connects to the SMTP server.

  2. A handshake is established.

  3. The client identifies itself and the sender/recipient.

  4. The message is transferred in ASCII format.

  5. The connection is terminated.

This entire process is driven by SMTP commands and responses exchanged between the client and server.

What Are the Commonly Used SMTP Server Commands?

Here are the most commonly used SMTP commands, in order of their typical usage:

1. HELO / EHLO

  • Purpose: Initiates the SMTP session.

  • HELO is used for basic SMTP servers; EHLO is used for servers that support Extended SMTP (ESMTP).

  • Syntax:

    HELO yourdomain.com
    

    or

    EHLO yourdomain.com
    
  • Response: 250 Hello yourdomain.com

2. MAIL FROM

  • Purpose: Specifies the sender's email address.

  • Syntax:

    MAIL FROM:
    
  • Response: 250 OK

3. RCPT TO

  • Purpose: Identifies the recipient's email address.

  • Syntax:

    RCPT TO:
    
  • Response: 250 OK (or error if address is not valid)

4. DATA

  • Purpose: Begins the message body transfer.

  • Syntax:

    DATA
    

    After this command, the server responds with:

    354 End data with .
    

    You then write the email content and end with a single period on a line:

    This is the message body.
    

5. RSET

  • Purpose: Resets the current mail session (clears all previous commands).

  • Syntax:

    RSET
    
  • Response: 250 OK

6. NOOP

  • Purpose: Sends a "no operation" command. It does nothing but ensures the server is responsive.

  • Syntax:

    NOOP
    
  • Response: 250 OK

7. VRFY

  • Purpose: Verifies whether an email address exists on the server.

  • Syntax:

    VRFY [email protected]
    
  • Response: Could return 250, 252, or 550 depending on the server configuration.

 Many modern servers disable this command for security reasons.

8. EXPN

  • Purpose: Expands a mailing list to reveal all recipients.

  • Syntax:

    EXPN listname
    
  • Response: Lists recipients or returns an error.

 Like VRFY, often disabled for privacy/security.

9. HELP

  • Purpose: Requests a list of available commands.

  • Syntax:

    HELP
    
  • Response: List of SMTP commands and descriptions.

10. QUIT

  • Purpose: Ends the SMTP session and disconnects.

  • Syntax:

    QUIT
    
  • Response: 221 Bye

Optional/Extended SMTP Commands (ESMTP)

When using EHLO, servers may support additional ESMTP extensions, such as:

STARTTLS

  • Purpose: Upgrades connection to a secure TLS/SSL.

  • Syntax:

    STARTTLS
    

AUTH

  • Purpose: Authenticates the client using login credentials.

  • Syntax:

    AUTH LOGIN
    

SMTP Command Example (Telnet Session)

Here's how a basic email session might look via Telnet:

telnet smtp.example.com 25
220 smtp.example.com ESMTP
EHLO test.com
250-smtp.example.com Hello
MAIL FROM:
250 OK
RCPT TO:
250 OK
DATA
354 End data with .
Subject: Test Email

This is a test.
.
250 OK: queued
QUIT
221 Bye

Security Risks of SMTP

SMTP by default is not encrypted, which exposes it to:

  • Man-in-the-middle attacks

  • Email spoofing

  • SMTP relay abuse

  • Phishing

Mitigations Include:

  • Enabling TLS encryption (STARTTLS)

  • Enforcing SMTP Authentication (AUTH)

  • Implementing SPF, DKIM, and DMARC

Conclusion

SMTP commands form the core of how email is transmitted across networks. Understanding these commands helps you troubleshoot and configure mail servers, and it is also used in cybersecurity and penetration testing. From sending emails using Telnet to detecting SMTP misconfigurations, this knowledge is useful in both offensive and defensive security.

To take this further with guided labs and an instructor, see our practical networking labs.

Related reading

Reference

For the authoritative details, see IETF RFCs.

Frequently Asked Questions

SMTP server commands are a set of text-based instructions used to send and relay email messages between servers and clients in an SMTP session.

HELO is the initial command in an SMTP session used to identify the sender's domain to the mail server.

EHLO is an extended version of HELO that supports additional features like authentication and STARTTLS in ESMTP.

The MAIL FROM command specifies the email address of the sender in the SMTP session.

RCPT TO defines the recipient's email address, telling the server where the message should be delivered.

DATA initiates the transfer of the email body content, including headers and message text, ending with a period (.) on a new line.

No, SMTP is not secure by default. Security can be added through STARTTLS and authentication mechanisms.

STARTTLS is an ESMTP command used to upgrade the plain connection to an encrypted one using TLS.

AUTH LOGIN allows the client to authenticate with the SMTP server using a base64-encoded username and password.

They can reveal valid email addresses and user lists, which attackers may exploit for phishing or spam.

Yes, Telnet is commonly used to manually test SMTP commands and troubleshoot mail server issues.

RSET resets the current mail transaction, clearing all previous command input without closing the connection.

QUIT properly ends the SMTP session and disconnects the client from the server.

Port 25 (default), 587 (submission), and 465 (secure SMTP with SSL) are commonly used.

NOOP does nothing except test the connection; it’s used to keep the connection alive.

Technically yes, if the server is misconfigured. That’s why proper authentication and DMARC/SPF policies are vital.

SMTP is used to send emails, while IMAP and POP3 are used to receive them.

Understanding SMTP helps with testing email services, identifying spoofing attempts, and securing mail flow.

An SMTP session is a connection between a mail client and server where commands are exchanged to transmit an email.

Use STARTTLS, enable authentication, restrict relay access, and implement SPF/DKIM/DMARC.

It’s a positive response from the server indicating the command was accepted.

354 is a response to the DATA command, indicating the server is ready to receive message content.

SMTP is not designed for file transfers but supports attachments via MIME encoding.

Mail clients use SMTP to send outbound email to the mail server, which then delivers it to the recipient.

SMTP relay is the process of one SMTP server forwarding email to another, typically for final delivery.

Use Telnet or OpenSSL to connect to the SMTP server and issue commands like HELO, MAIL FROM, etc.

Failures can occur due to invalid addresses, blocked IPs, or authentication issues.

This depends on the server, but typical limits are between 10MB and 25MB.

Yes, tools like Python’s smtplib or shell scripts can automate SMTP command execution.

The server will keep waiting for message completion, potentially causing a timeout.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.