Created
September 10, 2015 19:49
-
-
Save ehlertjd/d10e4f050e40f77b448d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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