How to test email server (SMTP) using Telnet command
As a Linux administrator, you may find yourself needing to troubleshoot or test your Simple Mail Transfer Protocol (SMTP) server to make sure it is working properly. One of the most efficient ways to do this is to use the telnet command.
Telnet allows you to manually connect to an SMTP server, send commands, and view live responses from the server, helping you diagnose problems or verify configurations. This guide will walk you through the process of testing an SMTP server using the telnet command.
Step 1: Open a Telnet session
To start testing the SMTP server, open a Terminal on your Linux system and start a Telnet session to the SMTP server.
telnet smtp.example.com 25
Replace smtp.example.com with the domain or IP address of the SMTP server and 25 with the appropriate port number if different.
Step 2: Understand the SMTP server greeting
After connecting, the SMTP server will respond with a greeting message, usually displaying the server's hostname and indicating that the server is ready to receive commands. This message will look something like this:
220 smtp.example.com ESMTP Postfix
If you receive this message, it means the connection was successful and the SMTP server is ready to accept commands.
Step 3: Start an SMTP conversation
EHLO Command : Start the conversation by identifying yourself to the SMTP server. Use the EHLO command followed by the domain or any placeholder like localhost.
EHLO localhost
The server will respond with a list of supported extensions and features:
250-smtp.example.com Hello localhost [127.0.0.1] 250-SIZE 10485760 250-PIPELINING 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250 SMTPUTF8
HELO Command : Alternatively, you can use the older HELO command instead of EHLO. However, EHLO is recommended as it indicates support for extended features.
HELO localhost
The response is usually simpler:
250 smtp.example.com Hello localhost [127.0.0.1]
Step 4: Specify the sender
Next, specify the sender's email address using the MAIL FROM command:
MAIL FROM:
The server will confirm the command:
250 2.1.0 Ok
Step 5: Specify recipients
Now, specify the recipient's email address using the RCPT TO command:
RCPT TO:
If the recipient is accepted, you will see:
250 2.1.5 Ok
If the recipient is invalid or not accepted by the server, you may see an error like the following:
550 5.1.1 : Recipient address rejected: User unknown in local recipient table
Step 6: Send message data
To send email data, use the DATA command:
DATA
The server will respond with a message indicating that it is ready to receive data:
354 End data with .
Now you can enter the body of your email. Start with the subject:
Subject: Test Email From: sender@example.com To: recipient@example.com This is a test email sent using Telnet.
After writing the email, end the data entry by typing a period (.) on a new line and pressing Enter :
.
The server will respond:
250 2.0.0 Ok: queued as ABC123DEF456
This indicates that the email has been accepted and queued for sending.
Step 7: End session
To end an SMTP session, use the QUIT command:
QUIT
The server will close the connection:
221 2.0.0 Bye
Step 8: Explaining common SMTP responses
During your interaction with the SMTP server, you will receive various response codes. Here are some common response codes:
- 220: Server is ready.
- 250: Requested mail action, completed.
- 354: Start typing letter; end with .
- 421: Service unavailable, channel closed.
- 450: Requested mail action not performed: Mailbox unavailable.
- 550: Requested action not taken: Mailbox unavailable.
Testing an SMTP server using Telnet is a valuable skill for any Linux administrator. It allows you to manually send commands and observe the server's response, making it easier to diagnose problems such as connection problems, incorrect SMTP configuration, or problems sending and receiving email. While Telnet is useful for testing, remember that it transmits data in plain text, so it should only be used in a secure, controlled environment. For production use, always ensure that your SMTP communications are encrypted using STARTTLS or other secure protocols.
You should read it
- How to set up SMTP server to send email from Gmail account
- How to Enable Telnet on Windows 7
- Learn about Telnet protocol
- How to set up your own email server on Windows PC
- How to Use Telnet on Mac OS X
- How to check for simple Linux server performance
- How to Activate Telnet in Windows 7
- Quiz: Learn about online email
May be interested
- Configure, set Incoming and Outgoing Email on SharePoint 2010 - Part 3in the previous sections of the article, we introduced you to some points in the process of configuring incoming email with sharepoint 2010, and this time we will continue with the rest, which is outgoing email. ..
- Check email encryption processto facilitate this analysis, it is good to 'talk' directly to your smtp or imap server.
- Configure, set Incoming and Outgoing Email on SharePoint 2010 - Part 2in the previous section of the article, we have introduced you to some of the basics of configuring and setting up sharepoint 2010 with the incoming and outgoing email features. and this time, we'll continue with some of the rest to complete this process, such as setting up active directory to display contact in outlook address book ...
- Configure, set Incoming and Outgoing Email on SharePoint 2010 - Part 1in the tutorial article below, we will introduce you to some basic steps to set up the rules applicable to incoming and outgoing emails via microsoft sharepoint 2010. application, for example, when enabling incoming feature sharepoint email, system members can automatically store emails and attachments that they send to addresses
- Secure secure SMTP mail flow between different Exchange Server 2007 organizationsin this article, i will show you how to create secure smtp traffic mail flow between exchange server 2007 systems in various exchange organizations. protecting smtp traffic between exchange 2007 organizations is much simpler than its previous versions.
- How to set up your own email server on Windows PCtoday, almost all popular web-mail providers, including gmail, yahoo and outlook, regularly scan users' email, which is big data. so should lovers and privacy promotion surrender to the power of big data companies?
- How to check for simple Linux server performancethere are many options for virtual private servers or professional servers in the market, so how do i know which server is the best and suitable for me?
- GOTO command in SQL Serverthe goto command is a simple jump command, which allows an unconditional jump program from goto to a location in the program that has a label (laber) command in the same function.
- Instructions for setting up an email account on iPhone (SMTP / IMAP / POP3)email is an extremely useful form of information exchange for people. catching this strong point, mobile phone manufacturers have set up an email application so that users can easily check the mail of companies, friends and partners .... anywhere mobile phones only need to connect to the internet.
- Clean command in Windowsthe clean command deletes all partitions or formats the volume from the current drive. the command applies to windows server (semi-annual channel), windows server 2019, windows server 2016, windows server 2012 r2, windows server 2012.