How to Use Telnet to Test SMTP Connectivity on Port 25

How to Use Telnet to Test SMTP Connectivity on Port 25

Telnet is a networking tool that allows you to test connectivity with services on other servers. By using it on port 25, you can verify whether your server is communicating correctly with an SMTP mail server, which is essential for diagnosing email delivery issues.

Prerequisite

Make sure Telnet is installed on your server. If it is not, you can install it with the following command:

  1. yum install telnet -y

 

1. Basic SMTP Connectivity Test

To verify whether your server can communicate with a destination mail server on port 25, open the terminal and run the following command, replacing DESTINATION_SERVER with the hostname or IP of the mail server you want to test:

  1. telnet DESTINATION_SERVER 25

For example, to test connectivity with Gmail's mail server:

  1. telnet gmail-smtp-in.l.google.com 25

If the connection is successful, you will see a response similar to this:

  1. Trying 142.250.xxx.xx...
  2. Connected to gmail-smtp-in.l.google.com.
  3. 220 mx.google.com ESMTP ready

The 220 code indicates that the SMTP server is responding correctly. If instead the connection hangs or you receive a "Connection refused" error, it means that port 25 is blocked or the destination server is unreachable.

To close the Telnet session, type:

  1. quit

 

2. Specify an Outgoing IP Address

If your server has multiple IP addresses and you need to control which IP the connection is made from, you can use the -b option. Replace OUTGOING_IP with the IP you want to connect from and DESTINATION_SERVER with the mail server:

  1. telnet -b OUTGOING_IP DESTINATION_SERVER 25

For example:

  1. telnet -b 192.168.1.100 gmail-smtp-in.l.google.com 25

This is especially useful when you need to verify whether a specific IP on your server has port 25 open or if it is being blocked by a blacklist.

3. Interpreting the Results

  • 220 Response: The connection was successful and the SMTP server is ready to receive commands.
  • Connection refused: The destination server rejected the connection. The port may be closed or the mail service may not be running.
  • Connection timed out: The connection could not be established. A firewall is likely blocking port 25.
  • 421 or 550 Response: The server responded but rejected the connection, usually due to security restrictions or because your IP is on a blacklist.
Alert
Telnet does not encrypt the connection, so any information sent or received during the session could be intercepted by third parties. Use this tool only for diagnostic purposes and never send real credentials through it.

 

Telnet is a quick and simple way to verify whether your server can communicate with other mail servers on port 25. It is one of the first tools you should use when diagnosing email delivery issues.

If you have any questions, we are available to help you through our chat system.