diff --git a/lib/imap.c b/lib/imap.c index 4a5c3f806d..33f8b1d2ee 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -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; diff --git a/tests/data/test1321 b/tests/data/test1321 index 7589534f7e..c7ae7daa58 100644 --- a/tests/data/test1321 +++ b/tests/data/test1321 @@ -59,7 +59,7 @@ imap://%HOSTIP:%IMAPPORT/1321 -u user:secret -p -x %HOSTIP:%PROXYPORT A001 CAPABILITY A002 LOGIN user secret A003 SELECT 1321 -A004 FETCH 1 BODY[TEXT] +A004 FETCH 1 BODY[] A005 LOGOUT diff --git a/tests/data/test801 b/tests/data/test801 index 67e10997f5..793b2781da 100644 --- a/tests/data/test801 +++ b/tests/data/test801 @@ -41,7 +41,7 @@ imap://%HOSTIP:%IMAPPORT/801 -u user:secret A001 CAPABILITY A002 LOGIN user secret A003 SELECT 801 -A004 FETCH 1 BODY[TEXT] +A004 FETCH 1 BODY[] A005 LOGOUT