Command list of IMAP and POP3 protocols. They can be used to test your server remotely over telnet connection.
Assume you set up pop3 and imap and want to check it out.
POP3 is quite simple protocol. I think you will make out how it’s work without any problem.
First, let’s go to check the POP3 server. Make sure that it bound at port 110:
# netstat -lnp | grep 110 tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 2779/dovecot
As you can see I use dovecot as server application and it’s works on all interfaces.
Next, make connection attempt:
# telnet 127.0.0.1 110 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. +OK Dovecot ready.
Now, we got server answer. Do authorization with command user and pass
USER user1 +OK PASS qwe +OK Logged in.
and LIST to see headers of all inbox mails:
LIST +OK 1 messages: 1 306 .
We have only one mail. First field of answer means
mail_id
.
To see whole mail use RETR mail_id:
RETR 1 +OK 306 octets Return-Path:Received: from d (node1 [10.0.30.1]) by mail.test.com (8.13.8/8.13.8) with SMTP id n8ONtVLG011279 for user1@test.com; Fri, 25 Sep 2009 03:04:08 +0300 Date: Fri, 25 Sep 2009 03:04:08 +0300 From: fd@test.com Message-Id: <200909250004.n8ONtVLG011279@mail.test.com> test
To delete it:
DELE 1 +OK Marked to be deleted.
This message marked as deleted and will be removed when you send command QUIT to server. To unmark messages use command RSET without any arguments:
RSET +OK
Use command QUIT to leave the server.
QUIT +OK Logging out.
Refer to RFC 1939 for more details.
By default IMAP listen port 143. Therefore let’s check it first:
# netstat -lnp | grep 143 tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 2779/dovecot
Try to connect:
# telnet localhost 143 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. * OK Dovecot ready.
Okay, we have got good answer. Now, we should authorize on server. Syntax is:
? LOGIN USER/ALIAS PASSWORD
For example:
? login user1 qwe ? OK Logged in.
To get folders list make:
? LIST "" "*" * LIST (\NoInferiors \UnMarked) "/" "INBOX" ? OK List completed.
In folder INBOX contain all incoming messages. To select it:
? SELECT INBOX * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted. * 1 EXISTS * 0 RECENT * OK [UNSEEN 1] First unseen. * OK [UIDVALIDITY 1253837819] UIDs valid * OK [UIDNEXT 2] Predicted next UID ? OK [READ-WRITE] Select completed.
1 EXISTS – means 1 incoming message. You can choose between see full message or only message body instead:
? FETCH message_number All
OR
? FETCH message_number Body
Let’s see whole message:
? FETCH 1 all
* 1 FETCH (FLAGS () INTERNALDATE "25-Sep-2009 03:04:12 +0300" RFC822.SIZE 306 ENVELOPE ("Fri, 25 Sep 2009 03:04:08 +0300" NIL ((NIL NIL "fd" "test.com")) ((NIL NIL "fd" "test.com")) ((NIL NIL "fd" "test.com")) NIL NIL NIL NIL "<200909250004.n8ONtVLG011279@mail.test.com>"))
? OK Fetch completed.
Exit user command is ? LOGOUT.
To learn more about IMAP refer to RFC 3501.