home

Below are command-line examples of IMAP commands that the script uses. This should explain a lot about how it works. Start with openssl at the command line--Windows or Linux. The following is just your input, not the IMAP server responses. uname is probably your email address. The mailbox syntax (SELECT) is specific to GMail, but I believe "Inbox" (without the quotes) will usually work.

% openssl s_client -crlf -connect imap.gmail.com:993
command1 LOGIN <uname> <password>
command2 SELECT "[Gmail]/All Mail"
command3 IDLE
DONE
command4 NOOP
command3 IDLE
DONE
command5 FETCH 1 (UID BODY.PEEK[HEADER.FIELDS (MESSAGE-ID)])
command6 LOGOUT

I admit my script doesn't bother to logout, so those 5 commands are all I use. The command prefix such as "command1" can be any number of strings--uou can just use a period, for example. Note that IDLE and DONE are part of the same command, so DONE doesn't use a prefix. Also, once you IDLE, the next command must be DONE. I recommand running these commands to see the output to better understand the script.

My script uses the command prefixes kwynnL, kwynnS, kwynnI, kwynnN, and kwynnF for LOGIN, SELECT, etc.

The NOOP command was recommended in several places to keep the connection going. I'm not sure if it's needed or DONE-IDLE-DONE is enough.

After you run LOGIN, you'll see a "CAPABILITY" list which must include "IDLE" for any of this to work.

Valid XHTML 1.0 Strict