]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
imap: Added the ability to FETCH a specific UID and SECTION
authorJiri Hruska <jirka@fud.cz>
Sat, 23 Feb 2013 21:05:19 +0000 (22:05 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Sat, 23 Feb 2013 21:11:47 +0000 (21:11 +0000)
Updated the FETCH command to send the UID and SECTION parsed from the
URL. By default the BODY specifier doesn't include a section, BODY[] is
now sent whereas BODY[TEXT] was previously sent. In my opinion
retrieving just the message text is rarely useful when dealing with
emails, as the headers are required for example, so that functionality
is not retained. In can however be simulated by adding SECTION=TEXT to
the URL.

Also updated test801 and test1321 due to the BODY change.

lib/imap.c
tests/data/test1321
tests/data/test801

index 4a5c3f806d6a14a9aef0612ab2809e97e4ed4e8c..33f8b1d2ee73e1293c51c33ab5e948fe94b1f57d 100644 (file)
@@ -1109,11 +1109,12 @@ static CURLcode imap_select(struct connectdata *conn)
 static CURLcode imap_fetch(struct connectdata *conn)
 {
   CURLcode result = CURLE_OK;
+  struct IMAP *imap = conn->data->state.proto.imap;
 
-  /* TODO: make this select the correct mail
-   * Use "1 body[text]" to get the full mail body of mail 1
-   */
-  result = imap_sendf(conn, "FETCH 1 BODY[TEXT]");
+  /* Send the FETCH command */
+  result = imap_sendf(conn, "FETCH %s BODY[%s]",
+                      imap->uid ? imap->uid : "1",
+                      imap->section ? imap->section : "");
   if(result)
     return result;
 
index 7589534f7e23e38448b180d3427e8f2303008edc..c7ae7daa58d2a953198c0cf7e2324c830b39fe64 100644 (file)
@@ -59,7 +59,7 @@ imap://%HOSTIP:%IMAPPORT/1321 -u user:secret -p -x %HOSTIP:%PROXYPORT
 A001 CAPABILITY\r
 A002 LOGIN user secret\r
 A003 SELECT 1321\r
-A004 FETCH 1 BODY[TEXT]\r
+A004 FETCH 1 BODY[]\r
 A005 LOGOUT\r
 </protocol>
 <proxy>
index 67e10997f5cb9de3456e85b070a61912eb0f8b77..793b2781da17971e513f6bada967b695410e8a5c 100644 (file)
@@ -41,7 +41,7 @@ imap://%HOSTIP:%IMAPPORT/801 -u user:secret
 A001 CAPABILITY\r
 A002 LOGIN user secret\r
 A003 SELECT 801\r
-A004 FETCH 1 BODY[TEXT]\r
+A004 FETCH 1 BODY[]\r
 A005 LOGOUT\r
 </protocol>
 </verify>