How to check SMTP command?

The Simple Mail Transfer Protocol (SMTP) is the standard protocol used for sending emails across the internet. To send and receive emails properly, your email client or application uses various SMTP commands to communicate with your email server. Some key things to know about SMTP commands:

How to check SMTP command?

  • SMTP commands allow the client and server to establish connections, send messages, validate recipients/senders, and manage the transmission of email
  • There are specific SMTP request commands issued by the client and response codes returned by the server
  • The basic SMTP workflow includes the client connecting to the server, authenticating, building the email, sending it, and finally disconnecting

By checking the SMTP commands used in the email sending process, you can troubleshoot issues and gain visibility into each step.

Why Check SMTP Commands

Here are some key reasons you may want to check the SMTP commands:

  • Identify errors – By inspecting the commands/responses you can pinpoint where failures are happening during email delivery.
  • Check configuration – Validate that the expected SMTP commands are being used based on how your email program/infrastructure is set up.
  • Improve efficiency – Detecting SMTP timeouts, errors establishing connections, or protocol mismatches allows you to optimize configurations.
  • Security analysis – Analysis of SMTP traffic can detect attacks, suspicious activity, or policy violations.
  • Compliance purposes – Logging and understanding SMTP commands may be necessary for regulated organizations.
  • Debug issues – When troubleshooting, analysis of SMTP commands gives low-level insight into email process failures.

How To Check SMTP Commands

There are several ways to check the SMTP commands used when sending email, depending on your specific system setup and what level of visibility you need:

  1. Check Application/Email Client Logs

Most email clients and servers automatically log SMTP activity, though at varying levels of detail. Possible options:

  • Webmail services – Gmail, Outlook 365 and other webmail providers may expose logs or delivery diagnostics showing SMTP commands used for sending mail through their standardized interfaces.
  • Mail transfer agents (MTAs) – Server programs like Sendmail, Postfix, and Exchange log SMTP connections in great detail, often at the protocol command level.
  • Native mail apps – Outlook, Apple Mail, Thunderbird and others log SMTP sends in varying degrees. Application settings may control logging specifics.
  1. Use Protocol Analyzers

Specialized tools can intercept SMTP connections for analysis purposes:

  • Telnet – Connect to port 25 or 587 on your SMTP server manually with telnet as a client. Interactively send SMTP commands and view server responses.
  • Wireshark – A packet analyzer that shows communication payloads. Can decode SMTP sessions to reveal commands sent.
  • Protocol analyzers – Dedicated tools like SMTP2Go parse SMTP connections, some specifically tailored for email analysis.
  1. Monitor Using Server Tools

For administrators overseeing servers, SMTP daemons and other mail infrastructure, logging and monitoring tools provide visibility:

  • Mail server logs – Applications like Exchange or Postfix record SMTP transactions which can be parsed with log analysis tools to extract commands.
  • SIEM systems – Security monitoring tools can be configured to ingest relevant SMTP logs and provide querying/reporting on commands.
  • APM software – Application performance tools track detailed app metrics including SMTP server traffic and response metrics.

Analyzing SMTP Commands in Action

As an example of checking SMTP commands in practice, consider using Telnet or Wireshark while manually sending a test email:

<pre> //TELNET SESSION $ telnet 25 Trying… Connected to Escape character is ‘^]’. 220 ESMTP Service Ready //Connection opened HELO myclient.local 250 Hello myclient.local //Client identifies itself MAIL FROM: [email protected] 250 [email protected] Sender ok //Sender is validated RCPT TO: [email protected] 250 Recipient ok //Recipient confirmed DATA 354 Enter mail body here From: Sender Name <[email protected]> //Email content and headers QUIT 221 Bye //Session closed </pre>

In this simplified SMTP transaction, you can clearly see the client opening a connection, introducing itself, specifying the sender/recipient, transmitting the message data, and finally quitting politely. By correlating the commands and responses to the desired workflow, you validate normal behavior versus detecting potential issues.

Key Takeaway

Checking SMTP commands provides deeper insight into your email infrastructure operations and can help identify or troubleshoot delivery issues. Depending on needs and access levels, SMTP commands can be analyzed via application logs, protocol analyzers, or server monitoring tools using techniques like the Telnet example session. Having visibility into the underlying commands allows you to inspect desired SMTP behavior compared to actual processes.


Using SMTP commands properly is key for reliable email delivery. Tracing and analyzing the commands involved in sending emails gives administrators and users better visibility when troubleshooting issues. By capturing and decoding SMTP protocol transactions, one can validate correct email client interactions and server responses at each stage such as connecting, sending messages, and finalizing transfers. The techniques discussed provide different mechanisms tailored for various systems to unlock SMTP command analytics. Whether leveraging application logs, protocol sniffing tools, or server monitors – checking SMTP commands delivers actionable intelligence around how email is sent.

Frequently Asked Questions

  1. What are some common SMTP commands?
    Some frequently used SMTP commands are HELO/EHLO, MAIL FROM, RCPT TO, DATA, QUIT.
  2. What SMTP responses indicate success?
    SMTP response codes in the 200s like 250 indicate successful processing of commands by the receiving SMTP server.
  3. Can I check Gmail’s SMTP activity?
    Yes, your Gmail account settings provide visibility into recent SMTP activity showing commands issued and server responses.
  4. What port does SMTP communicate over?
    The default simple SMTP port is 25. Implicit SSL SMTP uses port 465, while explicit TLS SMTP uses port 587.
  5. Where are SMTP logs located on Linux?
    Common Linux SMTP daemon logging directories are /var/log/maillog, /var/log/mail.log, /var/log/exim4.
  6. What tool traces SMTP packets?
    Wireshark can capture and parse SMTP session payloads to reveal commands sent and responses received.
  7. Can SMTP client applications log commands?
    Yes, email client apps like Thunderbird and Outlook can optionally be configured to log levels showing SMTP commands used in sending.
  8. Do cloud email providers show SMTP commands?
    Services like Office 365 and Gmail expose some SMTP telemetry in admin views but details may be limited.
  9. What causes SMTP 421 errors?
    A 421 SMTP server response means the server is rejecting/closing the connection or session typically due to timeout or a rejected command.
  10. How can I learn SMTP commands?
    Using a Telnet session to interactively connect to an SMTP server and issue manual commands is a great way to understand the protocol.
  11. Can SMTP-sent emails be traced?
    Yes, unique message transaction IDs generated during SMTP transactions can be used to trace message paths if logging captures them.
  12. What security attacks target SMTP?
    Some attacks like SMTP injection attempt to manipulate vulnerable SMTP daemons. Strict server hardening is key.
  13. Where would compromised SMTP credentials be risky?
    If an attacker obtained valid company SMTP credentials they could potentially transmit spam or malicious emails appearing to originate internally.
  14. What causes lost SMTP connections?
    Intermittent network issues, traffic spikes, protocol mismatches between misconfigured client/server, or firewall interruptions can sever SMTP sessions leading to failures.
  15. What special SMTP responses signal errors?
    Any SMTP responses in the 400 range signal client command errors while 500 range codes indicate server failures.
  16. How can you optimize SMTP performance?
    Baseline monitoring to identify bottlenecks, enable compression, enforce TLS encryption, optimize timeouts, update DNS records, expand resources, load balance infrastructure.
  17. Why enforce SMTP over TLS?
    Transport Layer Security (TLS) encrypts the SMTP session protecting privacy and ensuring authenticity. Security best practice for email delivery.
  18. How quickly does SMTP transmit large messages?
    SMTP lacks inherent transfer acceleration. Optimizations like compression or adding server resources can help increase message throughput.
  19. Can application logs provide SMTP forensics?
    Yes, server and email client application logs recording SMTP activity can supply forensic data revealing account misuse or cyber attacks related to mail transactions.
  20. What SMTP best practices prevent issues?
    Require valid certificates and encryption, enable server logging, restrict SMTP to authorized subnets internally, enforce sender/recipient validation, use TLS everywhere possible.

Leave a Comment