Was this page helpful?

Testing Mail Services

    Table of contents
    1. 1. SMTP
    2. 2. POP
    3. 3. IMAP

    SMTP

    Connect to the server you wish to test:

    $> telnet mailserver.example.com smtp
    

    The server should reply with:

    Trying mailserver.example.com...
    Connected to mailserver.example.com.
    Escape character is '^]'.
    220 mailtest ESMTP Postfix (Debian/GNU)
    

    Great! Postfix is listening and wants us to speak SMTP. First we need to be friendly:

    ehlo example.com
    

    Postfix appreciates our friendliness and tells us which features are available:

    250-my-new-mailserver
    250-PIPELINING
    250-SIZE 10240000
    250-VRFY
    250-ETRN
    250-STARTTLS
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250 DSN
    

    Hey, Postfix, we have a mail from steve@example.com:

    mail from:<matt@example.com>
    

    Looks like Postfix is happy with that because return codes that start with a '2' are good news:

    250 2.1.0 Ok
    

    Tell Postfix who the recipient of the mail is:

    rcpt to:<clark@example.com>
    

    Postfix accepts that:

    250 2.1.5 Ok
    

    Then we are ready to send the actual mail:

    data
    

    Postfix agrees and tells us we can send the actual mail now and end our input with a dot on an empty line:

    354 End data with <CR><LF>.<CR><LF>
    

    Okay, now type up an e-mail:

    Hi Matt,
    
    Just wanted to drop you a note.
    .
    

    Postfix tells us it has received the mail and queued under a queue ID:

    250 2.0.0 Ok: queued as A9D64379C4
    

    Thanks, Postfix, we are done:

    quit
    

     

    POP

    Let us try to create a POP3 connection and retrieve Matt's email:

    $> telnet localhost pop3
    

    The server replies:

    Trying mailserver.example.com...
    Connected to mailserver.example.com.
    Escape character is '^]'.
    +OK Dovecot ready.
    

    Login as Matt:

    user matt@example.com
    

    The server should accept that:

    +OK
    

    Send the password:

    pass summersun
    

    The server should recognize the correct password:

    +OK Logged in.
    

    Get a list of John's emails:

    list
    

    Dovecot will tell you that one email is in the mailbox:

    +OK 1 messages:
    1 474
    .
    

    Fetch that email number 1:

    retr 1
    

    Dovecot sends you the email:

    +OK 474 octets
    Return-Path: <clark@example.com>
    X-Original-To: matt@example.com
    Delivered-To: matt@example.com
    Received: from example.com (localhost [127.0.0.1])
        by ... (Postfix) with ESMTP id 692DF379C7
        for <matt@example.com>; Fri, 18 May 2007 22:59:31 +0200 (CEST)
    Message-Id: <...>
    Date: Fri, 18 May 2007 22:59:31 +0200 (CEST)
    From: clark@example.com
    To: undisclosed-recipients:;
    
    Hi Matt,
    
    Just wanted to drop you a note.
    .
    

    Close the connection to the POP3 server:

    quit
    

    The server will disconnect you:

    +OK Logging out.
    Connection closed by foreign host.
    

     

    IMAP

     

    $> telnet mailserver.example.com 143
    

    You should get a connection:

    Trying mailserver.example.com...
    Connected to mailserver.example.com.
    Escape character is '^]'.
    * OK Dovecot ready.
    

    IMAP commands always start with a number and reply to that command with the same number. So the following commands must be entered with the number at the beginning of each line.

    Login with username and password:

    1 login matt@example.com summersun
    

    Dovecot logs you in:

    1 OK Logged in.
    

    Ask Dovecot for a list of John's mail folders:

    2 list "" "*"
    

    Here comes the list:

    * LIST (\HasNoChildren) "." "INBOX"
    2 OK List completed.
    

    Select your inbox:

    3 select "INBOX"
    

    Dovecot gives you all kinds of information about that folder:

    * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
    * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
    * 1 EXISTS
    * 0 RECENT
    * OK [UIDVALIDITY 1180039205] UIDs valid
    * OK [UIDNEXT 3] Predicted next UID
    3 OK [READ-WRITE] Select completed.
    

    You see that one email exists. Fetch it:

    4 fetch 1 all
    

    IMAP will just give you basic information on the email:

    * 1 FETCH (FLAGS (\Seen) INTERNALDATE .........
    4 OK Fetch completed.
    

    To read the actual mail body you need to fetch it exlicitly:

    5 fetch 1 body[]
    

    Here it comes:

    * 1 FETCH (BODY[] {474}
    Return-Path: <clark@example.com>
    X-Original-To: matt@example.com
    Delivered-To: matt@example.com
    Received: from example.com (localhost [127.0.0.1])
            by ... (Postfix) with ESMTP id 692DF379C7
            for <matt@example.com>; Fri, 18 May 2007 22:59:31 +0200 (CEST)
    Message-Id: <...>
    Date: Fri, 18 May 2007 22:59:31 +0200 (CEST)
    From: clark@example.com
    To: undisclosed-recipients:;
    
    Hi Matt,
    
    Just wanted to drop you a note.
    )
    5 OK Fetch completed.
    

    Disconnect from the server:

    6 logout
    

    Dovecot logs you out:

    * BYE Logging out
    6 OK Logout completed.
    Connection closed by foreign host.
    
    Was this page helpful?
    Tag page (Edit tags)
    • No tags
    You must login to post a comment.
    Powered by MindTouch Core