user-avatar
Today is Friday
November 22, 2024

June 11, 2009

Accessing POP3 email accounts using telnet

by viggy — Categories: debian, linux, tech — Tags: , , Leave a comment
  • Coutsey to Bob Peers
  • The basics.

    About POP.

    POP is simply a protocol for retrieving emails from a remote server. The vast majority of mail
    providers use this protocol and it has been around for many years now. The protocol, in it’s
    simplest form, is just a few text commands sent from your computer over the internet which when received by the mail server prompt it to respond with the
    requested information. There’s only 4 or 5 basic commands we need to know to get started so it’s very simple.

    Before starting it’s important to know a few things:

    Mail server address.

    The address of your mail server, this will usually be of the form mail.domain.com. You should look at the settings in your email client or documentation about your
    email account to get this information.

    Security.

    In this demonstration we will be sending our account username and password unencrypted over the internet, if this is a major concern to you then you should not follow
    this exercise.

    Using telnet.

    If you make a mistake in a telnet session you cannot use backspace to delete the entry, you may have to press enter to get an error and then re-type the command or quit and start again.

    Connecting to the host.

    First open up a terminal and type the following, of course replacing mail.yourserver.dk with the address of your POP server:

    telnet mail.myserver.dk 110

    This should return something like:

    telnet mail.myserver.dk 110
    Trying 172.16.0.2...
    Connected to mail.myserver.dk (172.16.0.2).
    Escape character is '^]'.
    +OK Hello there.

    Logging in.

    Next we need to log in using the user command.

    user myusername
    +OK Password required.

    Now give our password using the pass command.

    pass ***********
    +OK logged in.

    The list command.

    To see a list of all the messages on the server and their sizes in bytes use the list command. If you specify a message number then only that message will be shown,
    i.e list 7.

    list
    +OK POP3 clients that break here, they violate STD53.
    1 22683
    2 19870
    3 785
    4 4475
    5 3221
    6 2972
    7 2412

    This just shows that I have 7 emails on the server, they are listed in order from oldest first to newest last.

    Reading the messages using retr.

    To read one of the messages use the retr command followed
    by the message number returned from the list command. It will return the whole message including all headers.

    retr 7
    +OK 2412 octets follow.
    Return-Path: <bounce@domain.com>
    X-Original-To: me@domain.dk
    Delivered-To: me@domain.dk
    Received: from mail-in1.inet.tele.dk (mail-in1.inet.tele.dk [194.182.148.158])
    by cirkeline.ingolf.dk (Postfix) with ESMTP id 554DA180D71
    for <me@domain.dk>; Wed, 1 Feb 2006 10:09:54 +0100 (CET)
    Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28])
    by mail-in1.inet.tele.dk (Postfix) with ESMTP id 2984C7049
    for <me@domain.dk>; Tue, 31 Jan 2006 18:37:01 +0100 (CET)
    Received: from frontend1.internal (mysql-sessions.internal [10.202.2.149])
    by frontend1.messagingengine.com (Postfix) with ESMTP id 2069DD335A7
    for <me@domain.dk>; Tue, 31 Jan 2006 12:36:18 -0500 (EST)
    Received: from web2.messagingengine.com ([10.202.2.211])
    by frontend1.internal (MEProxy); Tue, 31 Jan 2006 12:36:18 -0500
    Received: by web2.messagingengine.com (Postfix, from userid 99)
    id 1148513964; Tue, 31 Jan 2006 12:36:12 -0500 (EST)
    Content-Disposition: inline
    Content-Transfer-Encoding: 7bit
    Content-Type: text/plain
    MIME-Version: 1.0
    X-Mailer: MIME::Lite 5022 (F2.73; T1.15; A1.64; B3.05; Q3.03)
    Date: Tue, 31 Jan 2006 17:36:12 UT
    From: "Email Administrator" <bounce@domain.com>
    Reply-To: "Email Administrator" <webmaster@domain.com>
    To: me@domain.dk
    Subject: Your www.domain.com account activation
    Message-Id: <20060131173612.1148513964@web2.messagingengine.com>

    ..............................

    Reading the top n lines with top.

    The top command is used to read the top n lines of a message, the syntax is ‘top message n’ where n is the number of lines you wish to read. Note
    that the full headers will be returned along with a new line and then the n lines of the message body.

    top 3 5
    Headers appear here.....

    This is a multi-part message in MIME format.

    ------=_NextPart_000_0295_01C5A03F.3E4B4030
    Content-Type: text/plain;
    charset="iso-8859-1"

    The stat command.

    To see the total number and size of all messages issue the stat command.

    stat 
    +OK 7 56418

    Deleting messages using dele.

    To delete a message use dele followed by the message number, note that messages are not immediately deleted, they will only be deleted after quitting the session.

    dele 7
    +OK Deleted.

    The stat command again shows the message is gone.

    stat
    +OK 6 54006

    Resetting the account using rset.

    Since the message is only marked for deletion we can undelete the message (and any other marked for deletion) by using rset (for reset).

    rset
    +OK Resurrected.

    Again, stat shows the message is now back.

    stat
    +OK 7 56418

    To end the session use quit, this will now permanently delete the messages you deleted during this session.

    quit
    +OK Bye-bye.

    Summary

    It’s very simple to read your emails from a POP account using telnet by just remembering a few simple commands, what we have done here is basically exactly
    the same as an email client, like Thunderbird or Outlook Express, does when it retrieves your mail. Of course on a daily basis it’s much nicer to use a web interface
    or email client but in those situations where all you have is an internet connection then this is a great fall-back especially since nearly every computer will
    have telnet already installed.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>