使用libcurl实现imap协议
最近在做一个项目,要求用imap协议下载邮箱内的所有邮件,包括发件箱的。准备用libcurl实现(因为这个库跨平台),但是不知道怎么下手
curl_easy_setopt(pCurl, CURLOPT_URL, "imap.163.com");
curl_easy_setopt(pCurl, CURLOPT_USERPWD, "user:password");
这样只能下载收件箱里的第一封啊
[解决办法]
遍历啊,亲!
[解决办法]
IMAP
The path part of an IMAP request not only specifies the mailbox to list (Added in 7.30.0) or select, but can also be used to check the UIDVALIDITY of the mailbox and to specify the UID and SECTION of the message to fetch (Added in 7.30.0).
imap://user:password@mail.example.com - Performs a top level folder list
imap://user:password@mail.example.com/INBOX - Performs a folder list on the user's inbox
imap://user:password@mail.example.com/INBOX/;UID=1 - Selects the user's inbox and fetches message 1
imap://user:password@mail.example.com/INBOX;UIDVALIDITY=50/;UID=2 - Selects the user's inbox, checks the UIDVALIDITY of the mailbox is 50 and fetches message 2 if it is
imap://user:password@mail.example.com/INBOX/;UID=3/;SECTION=TEXT - Selects the user's inbox and fetches message 3 with only the text portion of the message
For more information about the individual components of an IMAP URL please see RFC 5092.