Skip to content

Instantly share code, notes, and snippets.

@ehlertjd
Created September 10, 2015 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehlertjd/d10e4f050e40f77b448d to your computer and use it in GitHub Desktop.
Save ehlertjd/d10e4f050e40f77b448d to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
#define USERNAME "user"
#define PASSWORD "password"
#define SERVER_URL "imap://mail.server.com/"
int main(void) {
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if( curl ) {
curl_easy_setopt(curl, CURLOPT_USERNAME, USERNAME);
curl_easy_setopt(curl, CURLOPT_PASSWORD, PASSWORD);
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// Do the first request
curl_easy_setopt(curl, CURLOPT_URL, SERVER_URL "Inbox");
res = curl_easy_perform(curl);
if( res != CURLE_OK ) {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
goto cleanup;
}
// Do the second request
curl_easy_setopt(curl, CURLOPT_URL, SERVER_URL "Drafts");
res = curl_easy_perform(curl);
if( res != CURLE_OK ) {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
cleanup:
curl_easy_cleanup(curl);
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment