Communicating with an email server using TELNET

You can diagnose email errors through the Linux command line using the TELNET command. You can communicate back and forth with the receiving server with TELNET to see why the email is being rejected to verify email bounce errors or to check if the server email ports are working. Below are the steps use TELNET to communicate with the server.

Important! In the code below, the Red commands are what you type and the Blue is what the server should respond back with. Also, this article is geared towards VPS and Dedicated server accounts; however, anyone can use the Linux command line on their local Linux computer. For information on shell access click here.

You can use TELNET with Windows command line; however, you will need to enable telnet on the Windows computer.

TELNET to an email server

You can communicate with a server using TELNET to find the exact error on the server in question. In this case, We will see if we can replicate the error when emails sent from [email protected] are bouncing sending to notexample.com. The basic syntax is as follows. (You can check any server port using telnet, not just port 25)

Command       Domain or IP      Port # telnet       example.com     25 

TELNET to the server that is refusing the email. In this case, the notexamplen.com server is rejecting the email.

[root@vps#### ~]$ telnet notexample.com 25 Trying 25.22.80.62... Connected to notexample.com. Escape character is '^]'. 220-fox.somenameserver.com ESMTP Exim 4.80 #2 Thu, 07 Mar 2013 08:06:11 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.

Type HELO localhost to receive a response from the receiving server. This will display the server name and IP.

HELO localhost 250 fox.somenameserver.com Hello localhost [205.134.240.204]

You can also type EHLO localhost to receive more information for the receiving server. This shows the extended server response with server name IP and some supported settings.

EHLO localhost 250-fox.somenameserver.com Hello localhost [205.134.240.204] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP

Now that you verified that the server is communicating back and forth, next, ask the server to check the sending email address. Type MAIL FROM: <[email protected]> FROM: SIZE=100 ( Supplement the [email protected] with the email address you are getting bounces with) and hit enter.

MAIL FROM: <[email protected]> SIZE=100 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1) Connection closed by foreign host.

The entire TELNET conversation should look like the following.

[root@vps#### ~]$ telnet notexample.com 25 Trying 25.22.80.62... Connected to notexample.com. Escape character is '^]'. 220-fox.somenameserver.com ESMTP Exim 4.80 #2 Thu, 07 Mar 2013 08:06:11 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. HELO localhost 250 fox.somenameserver.com Hello localhost [205.134.240.204] EHLO localhost 250-fox.somenameserver.com Hello localhost [205.134.240.204] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP MAIL FROM: <[email protected]> SIZE=100 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1) Connection closed by foreign host.

The example before shows that the receiving server notexample.com is rejecting email from [email protected] with a “550 No Such User Here” error.

10 thoughts on “Communicating with an email server using TELNET

    1. Hello Henry,

      It looks like you were trying to put an image in the post. If so, the link is not correct or not working. If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  1. I think I got  it going. Mail is quite strange in setting it up. The trick is that it wants to set the SMTP to 587 when the port setting is supposed to be 465 (at least that’s what it says in your information).

    587 is the only port that works with your recommended SMTP settings now, though port 465 used to work just fine in the past (Sever: secure161servconfig.com, Authenciation:Password,username:<email address>, password:<your password>). If settings get screwed up enough, Mail gives it up. Thereafter, the only way out is to start over. 

    Get a totally different response with port 587 than that of 465 and I think you will too. 

    1. Hello Henry,

      Thank you for contacting us. Since your available server ports for email have not changed, most likely the network you are connecting from, or your ISP is blocking the port. This is common with many ISP’s, or public networks.

      If you have any further questions, feel free to post them below.

      Thank you,
      John-Paul

  2. The problem I’m having is that while I CAN OPEN the port in Telnet, I CANNOT send via my client using SSL. I get the advice that the certificate doesn’t exist or that the certificate is expired or that the encryption is wrong (not 64 bit) depending on which client or method is being used (e.g., Mail, or direct access via another app that sends via secure server). What can be done to troubleshoot this? I tried to chat with your support (Matthew) nothing was resolved.

    1. Henry,

      I’m not really sure how you’re trying to send (I’m assuming this is an outgoing email). If you have the SSL settings for outgoing email correctly configured with your email client, then it will send the email using the secure connection. Our Email over SSL article should give you the necessary information for the correct setup.

      If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  3. I’m using Mac OS and the Terminal (application). What are the commands I would use to check the SMTP server port 465 with SSL?

     

  4. Hi, I am Trying to connect the server using windows cmd promt. just blank output I got. and nothing generated in logs aslo. I mean Request is not hitted to server. What could be the reoason ?

    1. Hello Pradeep,

      Thanks for the question. Just because you get a blank screen doesn’t mean it’s an error. You most likely have connected. When you telnet in, you must give a command afterward to continue working in the telnet connection. This a pretty commonly discussed issue. Check out this forum post. They explain exactly what you may be seeing.

      Regards,
      Arnel C.

Was this article helpful? Join the conversation!

Questions about our MailChannels Deployment? We have answers and are here to help!Learn More
+