Telnet to port 25 to test SMTP communication

  
                  This article describes how to telnet to port 25 on a computer that is running the Simple Mail Transfer Protocol (SMTP) service to resolve SMTP communication problems. By default, SMTP listens on port 25.

You can choose the appropriate troubleshooting steps below depending on the type of problem you are experiencing. For example, if you have problems sending mail through SMTP between two Microsoft Exchange 2000 Server servers, you can test the SMTP connection by using Telnet on the sending server to connect to port 25 on the target server. Or, if you are experiencing problems receiving SMTP mail from the Internet, you can test the connection of a host that is hosted on the Internet but not on your network to your SMTP server by following the steps outlined in this article.

More Information
There are many different variants of SMTP in the Microsoft product line. The SMTP service for the Microsoft Windows product line is included in Internet Information Services (IIS), while in Microsoft Windows NT Server 4.0, the SMTP service is included in the Option Pack. In newer versions of Windows, IIS has been integrated into the operating system, and you can add IIS using Add or Remove Programs in Control Panel. In addition, both Exchange 2000 and Microsoft Exchange Server 2003 use existing SMTP services and other features in IIS. Microsoft Exchange Server versions 4.0, 5.0, and 5.5 all contain their own versions of SMTP in the form of Internet Mail Connector (IMC) or Internet Mail Service (IMS).

Note: In Exchange 5.0 and later, the Internet Mail Connector (IMC) was renamed to Internet Mail Service.

Before starting a Telnet session, you must have the full SMTP email address of the target user to whom you want to send this test message. The email address must be in the following format: [email protected]
You can also have the fully qualified domain name (FQDN) or IP address of the server computer running the SMTP service (for example, 10.120.159.1). If the server is in your organization, you may already have this information. If the server is an external server, the easiest way to find this information is to use Nslookup.exe to find the DNS record that contains the information. For additional information about NSlookup, click the article number below to view the article in the Microsoft Knowledge Base: 200525 Using NSlookup.exe
For additional information on how to obtain Internet Mail Exchanger records, click the article below Number to view the article in the Microsoft Knowledge Base: 203204 XFOR: How to Obtain an Internet Mail Exchanger Record

Make sure that SMTP is started on the server that is running the SMTP service. To test if SMTP is up, you can run the basic tests listed in this article and verify that you receive a 220 message from a remote server. This will also verify if SMTP is running.

Note:

  • Some Telnet applications require you to turn on local echo to see the commands you type. To do this in a Microsoft Telnet session, type set local_echo at a command prompt.
  • In Microsoft Windows XP, you should type set localecho instead of set local_echo.

    Basic Testing
    Follow these steps to ensure that the host and remote SMTP server can communicate. If you receive the following error message after you type any of the following commands, the SMTP server is unable to recognize what you typed because of a syntax error or a command error:
    500 Command not recognized Check the command and type it again, Or verify that you are communicating directly with the Microsoft SMTP server.

    Note: Microsoft Telnet does not allow you to use the Backspace key. If you make a mistake while typing, you must press Enter and start typing the new command.

    In the following steps, you run Telnet from the command line. To open the command line, click Start, click Run, type cmd in the Open box, and then click OK.

  • You can start a Telnet session by using the Telnet command in the following format:

    Note: Press Enter after typing each line of content. telnet servernameport number
    For example, type: telnet mail.contoso.com 25
    Note: You can use server name Replace with the IP address or FQDN of the SMTP server you are connecting to. Remember to press Enter after typing each command.

    If this command works, you will receive a message from the SMTP server similar to the following:
    220 site.contoso.com Microsoft Exchange Internet Mail Connector <IMC version number>


    Note: Because there are many different versions of Microsoft SMTP or third-party SMTP servers, you may receive different messages from the receiving server. However, you will definitely receive a 220 message containing the FQDN of the server and the version of SMTP. In addition, all versions of Microsoft SMTP include the word "Microsoft" in the 220 message.

  • Start communication by typing: EHLO test.com
    Note: You can use the HELO command, but EHLO is a verb in the extended SMTP verb set that is supported by all current Microsoft implementations of SMTP The verb set. Unless you think there is a problem with the extended SMTP verb, it's best to use EHLO.

    If the command is successful, you will receive the following message:
    250 OK


  • Type the following command to notify the receiving SMTP server of the sender of the message: MAIL FROM :[email protected]
    Note: This address can be any SMTP address you want to use, but it is best to consider the following:
  • Some SMTP mail systems filter messages based on the MAIL FROM: address, and Some IP addresses are blocked from connecting to the SMTP mail system, or if the connection IP address does not match the domain in which the SMTP mail system is located, it also prohibits the address from sending email to the SMTP mail system. In this case, the domain is test.com.
  • If you are not using a valid email address when sending mail, you will not be able to determine if there is a problem sending the message because the non-delivery report (NDR) cannot reach the invalid IP address. If you use a valid email address, you will receive the following message from the SMTP server:
    250 OK - MAIL FROM [email protected]




  • Type The following command notifies the receiving SMTP server of the recipient of the message.

    Note: It is best to always use the valid recipient SMTP address in the domain you are sending to. For example, if you are sending to [email protected], you must ensure that [email protected] exists in the domain. Otherwise, you will receive an NDR.

    Type the following command using the SMTP address of the person you are sending to: RCPT TO:[email protected]
    You will receive the following message:
    250 OK - Recipient User@ Domain.Com


  • Type the following command to inform the SMTP server that you are ready to send data: DATA
    You will receive the following message:
    354 Send data. End With CRLF.CRLF
  • You are now ready to start typing the 822/2822 part of the message. Users will see this part of the message in their inbox. Type the following command to add the subject line: Subject:test message
    Press Enter twice. This command does not display any information.

    Note: Press Enter twice to be consistent with Request for Comments (RFC) 822 and 2822. It specifies that the 822 command must be followed by a blank line.
  • Type the following command to add the message body: This is a test message you will not see a response from this command.
  • Type a period (.) in the next blank line, then press Enter key. You will receive the following message:
    250 OK


  • Type the following command to close the connection: QUIT
    You will receive the following message:
    221 closing connection


  • Verify that the recipient has received the message you sent. If there are any error event messages in the application event log, or if there is a problem receiving the mail, check the configuration or communication of the host.

    Advanced Testing
    In addition to the basic testing steps listed earlier in this article, you can also use a delivery receipt to test your mail in both directions. You can use this method to verify that the SMTP server can accept inbound connections and generate a delivery receipt for the sender to test the outbound connection to the SMTP server.

    To request a delivery receipt for a test mail, see step 4 of the "Basic Testing" section of this article to ensure that the information provided is a valid email address that can receive delivery receipts. Then in step 5 of the "Basic Testing" section of this article, type the following command in a Telnet session: RCPT TO:[email protected] notify=success,failure
    ,

Copyright © Windows knowledge All Rights Reserved