Difference between revisions of "Testing IMAP via telnet"

From Linuxintro
imported>ThorstenStaerk
(New page: This shows how you query your imap server from the command line, e.g. for testing purposes. This example has been tested with SUSE 10.3 but should work same or similar with any Linux. $ t...)
 
 
(3 intermediate revisions by 2 users not shown)
Line 8: Line 8:
 
  1 LOGIN testuser password
 
  1 LOGIN testuser password
 
  1 OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID LOGINDISABLED ACL RIGHTS=kxte QUOTA MAILBOX-REFERRALS NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT SORT=MODSEQ THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE CONDSTORE IDLE X-NETSCAPE URLAUTH] User logged in
 
  1 OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID LOGINDISABLED ACL RIGHTS=kxte QUOTA MAILBOX-REFERRALS NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT SORT=MODSEQ THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE CONDSTORE IDLE X-NETSCAPE URLAUTH] User logged in
Now you select the inbox. Please note this varies between imap servers - [[cyrus]] calls the inbox "INBOX", [[Courier-IMAP]] calls it "Inbox":
+
Now you list all folders with the command
 +
. list "" "*"
 +
And you get an answer like
 +
* LIST (\HasNoChildren) "." "Trash"
 +
* LIST (\HasNoChildren) "." "test"
 +
* LIST (\HasNoChildren) "." "Sent"
 +
* LIST (\HasNoChildren) "." "Drafts"
 +
* LIST (\HasNoChildren) "." "INBOX"
 +
. OK List completed.
 +
Now you select the inbox. Please note this varies between imap servers - cyrus calls the inbox "INBOX", [[Courier-IMAP]] calls it "Inbox":
 
  1 SELECT Inbox
 
  1 SELECT Inbox
 
  * FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
 
  * FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
Line 19: Line 28:
 
  * OK [URLMECH INTERNAL]
 
  * OK [URLMECH INTERNAL]
 
  1 OK [READ-WRITE] Completed
 
  1 OK [READ-WRITE] Completed
''You see that 1 mail exists''. You want to know if there are any items in the inbox:
+
''You see that 1 mail exists''. You want to know if there are any items in the inbox, so first do the LIST command:
 
  4 LIST "" "INBOX"
 
  4 LIST "" "INBOX"
 
  * LIST (\HasChildren) "." "INBOX"
 
  * LIST (\HasChildren) "." "INBOX"
 
  4 OK Completed (0.000 secs 3 calls)
 
  4 OK Completed (0.000 secs 3 calls)
 +
and now the fetch command:
 
  3 uid fetch 2:* (UID RFC822.SIZE FLAGS ENVELOPE BODY.PEEK[HEADER.FIELDS (REFERENCES)])
 
  3 uid fetch 2:* (UID RFC822.SIZE FLAGS ENVELOPE BODY.PEEK[HEADER.FIELDS (REFERENCES)])
 
  * 1 FETCH (FLAGS (\Seen) UID 1 RFC822.SIZE 3408 ENVELOPE ("Tue, 5 Aug 2008 07:23:13 +0200" "[Kde-pim] making Konqueror a Kontact plugin to add URLs to Kontact side bar" (("Who Ever" NIL "wever" "not.net")) (("Who Ever" NIL "wever" "not.net")) (("KDE PIM" NIL "kde-pim" "kde.org")) ((NIL NIL "kde-pim" "kde.org")) NIL NIL NIL "<20080805052313.GC2844@not.net>") BODY[HEADER.FIELDS (REFERENCES)] {2}
 
  * 1 FETCH (FLAGS (\Seen) UID 1 RFC822.SIZE 3408 ENVELOPE ("Tue, 5 Aug 2008 07:23:13 +0200" "[Kde-pim] making Konqueror a Kontact plugin to add URLs to Kontact side bar" (("Who Ever" NIL "wever" "not.net")) (("Who Ever" NIL "wever" "not.net")) (("KDE PIM" NIL "kde-pim" "kde.org")) ((NIL NIL "kde-pim" "kde.org")) NIL NIL NIL "<20080805052313.GC2844@not.net>") BODY[HEADER.FIELDS (REFERENCES)] {2}
Line 35: Line 45:
  
 
= See also =
 
= See also =
 +
* [[telNet]]
 
* http://networking.ringofsaturn.com/Protocols/imap.php
 
* http://networking.ringofsaturn.com/Protocols/imap.php
 
* http://www.networksorcery.com/enp/protocol/imap.htm
 
* http://www.networksorcery.com/enp/protocol/imap.htm
 
* http://www.networksorcery.com/enp/rfc/rfc3501.txt
 
* http://www.networksorcery.com/enp/rfc/rfc3501.txt

Latest revision as of 19:59, 30 December 2020

This shows how you query your imap server from the command line, e.g. for testing purposes. This example has been tested with SUSE 10.3 but should work same or similar with any Linux.

$ telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=DIGEST-MD5 AUTH=CRAM-MD5 SASL-IR] tweedleburg Cyrus IMAP4 v2.3.8 server ready

Now you type the login command with a strange number preceeding:

1 LOGIN testuser password
1 OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID LOGINDISABLED ACL RIGHTS=kxte QUOTA MAILBOX-REFERRALS NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT SORT=MODSEQ THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE CONDSTORE IDLE X-NETSCAPE URLAUTH] User logged in

Now you list all folders with the command

. list "" "*"

And you get an answer like

* LIST (\HasNoChildren) "." "Trash"
* LIST (\HasNoChildren) "." "test"
* LIST (\HasNoChildren) "." "Sent"
* LIST (\HasNoChildren) "." "Drafts"
* LIST (\HasNoChildren) "." "INBOX"
. OK List completed. 

Now you select the inbox. Please note this varies between imap servers - cyrus calls the inbox "INBOX", Courier-IMAP calls it "Inbox":

1 SELECT Inbox
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen \*)]
* 1 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1217915379]
* OK [UIDNEXT 2]
* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
* OK [URLMECH INTERNAL]
1 OK [READ-WRITE] Completed

You see that 1 mail exists. You want to know if there are any items in the inbox, so first do the LIST command:

4 LIST "" "INBOX"
* LIST (\HasChildren) "." "INBOX"
4 OK Completed (0.000 secs 3 calls)

and now the fetch command:

3 uid fetch 2:* (UID RFC822.SIZE FLAGS ENVELOPE BODY.PEEK[HEADER.FIELDS (REFERENCES)])
* 1 FETCH (FLAGS (\Seen) UID 1 RFC822.SIZE 3408 ENVELOPE ("Tue, 5 Aug 2008 07:23:13 +0200" "[Kde-pim] making Konqueror a Kontact plugin to add URLs to Kontact side bar" (("Who Ever" NIL "wever" "not.net")) (("Who Ever" NIL "wever" "not.net")) (("KDE PIM" NIL "kde-pim" "kde.org")) ((NIL NIL "kde-pim" "kde.org")) NIL NIL NIL "<20080805052313.GC2844@not.net>") BODY[HEADER.FIELDS (REFERENCES)] {2}

)
3 OK Completed (0.000 sec)

Now you type the logout command:

1 LOGOUT
* BYE LOGOUT received
1 OK Completed
Connection closed by foreign host.

See also