Saturday, July 13, 2013

Sending and Receiving Email via Telnet


          E-mailing is the exchanging of digital messages between the sender/s and the recipient/s across the Internet. Typically, we go to internet browsers, then proceed and login to web-based email clients such as Yahoo! Mail and Gmail; or we make use of locally installed email clients such as Microsoft Outlook and Thunderbird to access and manage our email accounts.

          In the contrary, there could be an instance that there’s an immediate necessity to send or access an email however we are restricted to use browsers. It could also be that the browsers are accessible but the friendly UIs provided by the email servers are suddenly not.

       One approach to address this problem without the use of the readily available Email Applications/ Clients/Readers is via Telnet. Telnet is a network protocol used on the Internet or local area networks that enables to run programs remotely and facilitates remote administration. Consequently, this allows to control a server and to communicate with other servers in the network.

          Through Telnet, an email transmission can be done across Internet Protocol (IP) networks with the use of an Internet standard, Single Mail Transfer Protocol (SMTP). User-level client mail applications typically only use SMTP to send messages to a mail server for relaying. On the other hand, Post Office Protocol (POP) or the Internet Message Access Protocol (IMAP) is used to receive messages. With accurate commands and parameters, sending and receiving messages can be successfully done via Telnet.

The PROCESS

Parameters and Requirements

The following parameters and requirements are needed to send and receive messages: Internet Connection; Command Prompt; Base64 Converter; SMTP server address (e.g. smtp.gmx.com); SMTP port number (e.g. 25); SMTP username; SMTP password; POP server address (e.g. pop.gmx.com); POP port number (e.g. 110);  POP username; POP password; Recipient’s email address; and Required TLS/SSL (NO).

Enabling Telnet

          There are some operating systems in which Telnet is not enabled by default. To be able to run the Telnet Prompt in command line, Telnet must be enabled first. To do so in Windows 7, click the Start button on the taskbar, proceed to Control Panel and select Programs and Features. Then, click Turn Windows Features On or Off. Among the list that would appear, check the checkbox for Telnet Client and hit Ok.

            Telnet is now accessible using Command Prompt.

Sending Email

          In command prompt, email can be sent via Telnet with the exchange of conversations or commands between the Server (S) and the Client (C). The command window is not case-sensitive to commands. Thus, either uppercase or lowercase letters may be used. As the Client, the following step-by-step commands and parameters must be encoded, to be followed by the corresponding Server’s response:

1st,
    C: telnet smtp.gmx.com 25

          The “smtp.gmx.com” is the designated SMTP server address for the GMX Mail. The “25” next to it is the standard SMTP port number. However, in some systems, this is blocked resulting to connection failure as shown in Figure 1. Instead, port 587 is used. Once entered, a new starting command line appears. Figure 2 and 3 reveals that a connection via Telnet is established using port 587.

Figure 1. Connecting to an SMTP server address on a blocked port 25

Figure 2. Connecting to an SMTP server address on port 587

Figure 3. Server response after establishing connection on port 587

2nd,
    C: ehlo 

        The client sends this command to the SMTP server to identify itself and initiate the SMTP conversation. The domain name or IP address of the SMTP client is usually sent as an argument together with the command (e.g. “EHLO client.example.com”). “EHLO” alone can also be done. “HELO” can also be used instead of “EHLO”. 

    S: 250-mail.gmx.com GMX Mailservices 
        250-8BITMIME 
        250-ENHANCEDSTATUSCODES 
        250-SIZE 
        250-AUTH=LOGIN PLAIN 
        250-AUTH LOGIN PLAIN
        250 STARTTLS

3rd,
    C: auth login

          This command authenticates the client to the server.

    S: 334 VXNlcm5hbWU6

          The server gives a base64 encoded scheme. It must be decoded to know its message using a base64 converter. You can find online base64 converters to be used in decoding the message. Decoding results to “Username:”.

4th,
    C: **********

          In return, the client (C) must provide an email address needed to access. The email address must be encoded in base64 scheme. You can use online base64 converter to know the base64 conversion of the email address.

    S: 334 UGFzc3dvcmQ6

          This is another base64 code, decoded as “Password:”.

5th,
    C: **********

          Herewith, a base64 scheme for the password of the email address provided must be given in response to the server.

    S: 235 2.7.0 Go ahead {mp-eu004}

          This indicates that authentication was successfully done and sending mail is now permitted.

6th,
    C: mail from: <******@gmx.com>
          
          This states the email address of the mail sender.

    S: 250 2.1.0 ok {mp-eu001}

7th,
    C: rcpt to: <******@hotmail.com>

         This states the email address of the mail recipient.

    S: 250 2.1.5 ok {mp-eu001}

8th,
    C: data

        This command implies that the sender is about to deliver the header and the body of the message to the server.

    S: 354 mail.gmx.com Go ahead {mp-eu001}

9th,
    C: from: <******@gmx.com>
         to: <******@hotmail.com>
         subject: telnet

         (the message)
         .

          The first three lines correspond to the header of the message. Stating only the subject, omitting the first two lines, is also acceptable in some domains. Then, a double enter is done followed by the body of the message. To end the message to be sent, a period ( ) is encoded on a line on its own.

    S: 250 2.6.0 Message accepted {mp-eu005}

10th,
    C: quit

          This is used if the conversation between the server and the client must already be ended.
      
     S: 221 2.0.0 GMX Mailservices {mp-eu005}

          The connection to the host will suddenly be lost.

The overall procedure is evidently illustrated in Figure 4.

Figure 4. Successfully sending email via Telnet

          It must be noted that basic Telnet does not support email clients that require TLS/SSL, like the case of Gmail. After executing the first three steps stated above, Telnet will ask to issue a STARTTLS command before proceeding to any commands in sending mail. After which, a reply “Ready to start TLS” from the server will be received. Continue to follow the commands stated above will always lead to a lost in connection from the host. Such instance is observed in Figure 5 after accessing Telnet and using Gmail with an SMTP server address “smtp.gmail.com”. On the other hand, email clients which do not require TLS/SSL will be able to perform those step-by-step commands via Telnet and successfully send email.

Figure 5. Sending email via Telnet using SMTP server with TLS/SSL required

          Moreover, commands must be encoded carefully to avoid typo errors. What has been encoded can’t be undone. It can be observed that the commands can be overwritten but it has no effect. Still, the server will read the wrong command before it was overwritten and will give such response.

Receiving Email

          The same with sending email, typo errors must be avoided in receiving email via Telnet in a command prompt. To start with, make sure that the POP setting of the email client to be used is enabled. Once enabled, receiving messages in command window can be done as follows:

1st,
    C: telnet pop.gmx.com 110

          The “pop.gmx.com” is the pop server address for GMX Mail. It is followed by the standard pop port number “110”. GMX Mail has a free and readily enabled POP.
    
    S: +OK POP server ready H migmx017

          This response allows the client to start logging in to his account.

2nd,
    C: user ******@gmx.com

          This accesses the GMX Mail username.

    S: +OK password required for user "******@gmx.com"

          Here, the server asks for the password of the account.

3rd,
    C: pass **********

          This completes the logging in process, with the password.

    S: +OK mailbox "mojazel@gmx.com" has 8 messages (61895 octets) H migmx017

          This indicates the number of messages the email account has received.

4th,
    C: list

          This command asks for the list of messages the email account has received. Figure 6 shows the list of messages, as seen from a section of the command window.

Figure 6. List of messages received

5th,
    C: retr 8

          The “retr” asks for the retrieval of a specific message received. It is followed by the number of that message on the list. Asking for the message in number 8 will be followed by a server’s response as shown in Figure 7.

Figure 7.A. Content of the message “8” retrieved


Figure 7.B. (Continued) Content of the message “8” retrieved

          The encircled part refers to the body of the message sent to the mail account.

6th,
    C: quit

          This command ends the program.

    S: +OK POP server signing off

          After signing off, the connection to the host will be lost.

The overall procedure is illustrated in Figure 8.

Figure 8.A. Successfully receiving email via Telnet
Figure 8.B. (Continued) Successfully receiving email via Telnet

Still encountering problems with your emails??..FIND SOLUTIONS HERE

No comments:

Post a Comment