cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: How to fetch pop3 mail using libcurl

From: <mushubi_at_sympatico.ca>
Date: Fri, 21 Oct 2011 12:34:23 +0000

> Allow me to give you a very simple one written on demand:
>
> #include <stdio.h>
> #include <curl/curl.h>
>
> int main(void)
> {
> CURL *curl;
> CURLcode res;
>
> curl = curl_easy_init();
> if(curl) {
> curl_easy_setopt(curl, CURLOPT_URL,
> "pop3://user:password_at_example.com");
> res = curl_easy_perform(curl);
>
> /* always cleanup */
> curl_easy_cleanup(curl);
> }
> return 0;
> }
>
This is close to what I tried. This is part of my code
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.gmail.com:995");
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_easy_setopt(curl, CURLOPT_USERNAME, "my_userid");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "my_password");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); /* write_data is my callback function */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
curl_easy_perform(curl);This is what I observe when I run the code
* About to connect() to pop.gmail.com port 995 (#0)
* Trying 209.85.225.108... * connected
* response reading failed
> QUIT
* response reading failed
* Closing connection #0
response reading failedI am using the same callback function that I use for the http protocol where it works fine.
This is the function.static int write_data(char *data, size_t size, size_t nmemb, std::string *buffer)
{
 int result = 0;
 if (buffer != NULL)
 {
  buffer->append(data, size * nmemb);
  result = size * nmemb;
 }
 return result;
}paschal.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-21