什么是IMAP协议
IMAP核心功能特性
邮件存储与同步:
在线访问:
多文件夹支持:
部分下载与缓存机制:
状态保留:
并发访问能力:
安全传输:
扩展性:
与SMTP协议的配合
IMAP协议工作方式
Foxmail客户端IMAP相关配置
IMAP协议常见指令
CAPABILITY:
LOGIN 或 AUTHENTICATE:
SELECT 或 EXAMINE:
CREATE:
DELETE:
RENAME:
SUBSCRIBE 和 UNSUBSCRIBE:
LIST:
STATUS:
APPEND:
FETCH:
STORE:
SEARCH:
COPY:
CHECK:
EXPUNGE:
NOOP:
LOGOUT:
指令演示
[root@VM-4-12-centos ~]# telnet 0 143 Trying 0.0.0.0... Connected to 0. Escape character is '^]'. * OK Coremail System IMap Server Ready # 通过LOGIN命令登录。a01表示命令编号,每个命令编号不要重复;后面跟着的是账号和密码。如果想做相关测试,只需要复制相关命令。 a01 LOGIN t1@mailabc.cn yiWFnAPfFweU9vPT a01 OK LOGIN completed # 列出可用命令 a02 CAPABILITY * CAPABILITY IMAP4rev1 XLIST SPECIAL-USE ID LITERAL+ STARTTLS APPENDLIMIT=20971520 UIDPLUS a02 OK CAPABILITY completed # 列出文件夹列表,相关参数可以查阅其他资料 a03 LIST "" "*" * LIST () "/" "INBOX" * LIST (\Drafts) "/" "Drafts" * LIST (\Sent) "/" "Sent Items" * LIST (\Trash) "/" "Trash" * LIST (\Junk) "/" "Junk E-mail" * LIST () "/" "Virus Items" a03 OK LIST Completed # 选择一个邮件箱(文件夹),参数对应LIST命令输出的文件夹信息 a04 SELECT "INBOX" * 7 EXISTS * 0 RECENT * OK [UIDVALIDITY 1] UIDs valid * FLAGS (\Answered \Seen \Deleted \Draft \Flagged) * OK [PERMANENTFLAGS (\Answered \Seen \Deleted \Draft \Flagged)] Limited a04 OK [READ-WRITE] SELECT completed # 通过FETCH命令获取编号1-2的UID信息,后续对邮件的操作基本上都是根据UID来进行,可以理解这是每封邮件唯一识别号 a05 FETCH 1:2 (UID) * 1 FETCH (UID 1681789653) * 2 FETCH (UID 1681789654) a05 OK Fetch completed # 通过UID FETCH命令获取特定邮件的FLAGS标志,如未读、已读 a06 UID FETCH 1681789653 FLAGS * 1 FETCH (UID 1681789653 FLAGS (\Seen)) a06 OK Fetch completed # 通过UID FETCH指令获取某封邮件的全部摘要信息 a07 UID FETCH 1681789653 ALL * 1 FETCH (UID 1681789653 INTERNALDATE "18-Apr-2023 11:47:33 +0800" FLAGS (\Seen) ENVELOPE ("Tue, 18 Apr 2023 11:47:33 +0800 (GMT+08:00)" "=?UTF-8?B?5qyi6L+O5L2/55SoQ29yZW1haWznlLXlrZDpgq7ku7bns7vnu58vV2VsY29tZSB0byB0aGUgQ29yZW1haWwgZS1tYWlsIHN5c3RlbQ==?=" ((NIL NIL "postmaster" "mailabc.cn")) ((NIL NIL "postmaster" "mailabc.cn")) ((NIL NIL "postmaster" "mailabc.cn")) ((NIL NIL "t1" "mailabc.cn")) NIL NIL NIL "<792468312.0.1681789653872@VM-4-12-centos>") RFC822.SIZE 7766) a07 OK Fetch completed # 通过UID FETCH指令获取某封邮件的BODY正文原文信息 a08 UID FETCH 1681789653 BODY[TEXT] * 1 FETCH (UID 1681789653 BODY[TEXT] {7251} =91;"> <div id="3D"head"" style="3D"background-color:" #0079b3;"=""> ... # 正常来说,这里会输出一大段信息,这里做了省略 a08 OK Fetch completed # 创建名为test1的文件夹 a09 CREATE test1 a09 OK mailbox created # 删除名为test1的文件夹 a10 DELETE test1 a10 OK mailbox deleted # 通过STATUS获取收件箱的状态信息 a11 STATUS "INBOX" (MESSAGES RECENT UNSEEN UIDNEXT UIDVALIDITY) * STATUS "INBOX" (MESSAGES 7 RECENT 0 UIDVALIDITY 1 UNSEEN 0) a11 OK STATUS completed
温馨提示:上述演示内容基于Coremail邮件系统,不同厂商的系统IMAP协议的支持程度有所不同。由于命令较多、参数复杂,有兴趣的同学可以查阅相关资料了解更详细的信息。如对本文感兴趣,可以私信我。