Advertisement
Momir

Čitanje i funkcije nad mejlovima

Feb 26th, 2020
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <curl/curl.h>
  4.  
  5. int main(void)
  6. {
  7.     CURL* curl;
  8.     CURLcode res = CURLE_OK;
  9.  
  10.     curl = curl_easy_init();
  11.     if (curl) {
  12.         /* Set username and password */
  13.         curl_easy_setopt(curl, CURLOPT_USERNAME, "ime.prezime@gmail.com");
  14.         curl_easy_setopt(curl, CURLOPT_PASSWORD, "Sifra");
  15.        
  16.         /*Otvaranje mejla za funkcije koje koriste imap*/
  17.         //curl_easy_setopt(curl, CURLOPT_URL, "imaps://imap.gmail.com:993/INBOX/");
  18.        
  19.         /*Čitanje određenog mejla (u ovom slučaju 2) preko imap protokola*/
  20.         //curl_easy_setopt(curl, CURLOPT_URL, "imaps://imap.gmail.com:993/INBOX/;MAILINDEX=2");
  21.        
  22.         /*Čitanje (ili otvaranje ako se koristi još neka funkcija) određenog mejla (u ovom slučaju 4) preko pop3 protokola*/
  23.         //curl_easy_setopt(curl, CURLOPT_URL, "pop3s://pop.gmail.com:995/4");
  24.  
  25.         /*Preusmeravanje primljenih podataka u fajl*/
  26.         //FILE* fajl = fopen("outuput.txt", "w");
  27.         //curl_easy_setopt(curl, CURLOPT_WRITEDATA, fajl);
  28.  
  29.         /*Uključivanje debuggera (ispisuje procese kojie se trenutno odvijaju) - nebitno*/
  30.         //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
  31.  
  32.         /*Brisanje određenog mejla preko pop3 protokola*/
  33.         //curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
  34.         //curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELE");
  35.  
  36.         /*Pretraga mejlova preko imap protokola, za više search komandi: https://tools.ietf.org/html/rfc3501#section-6.4.4 */
  37.         //curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "SEARCH TEXT <jebise>");
  38.         //curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "SEARCH UNSEEN");            
  39.    
  40.         /* Perform the fetch */
  41.         res = curl_easy_perform(curl);
  42.  
  43.         /* Check for errors */
  44.         if (res != CURLE_OK)
  45.             fprintf(stderr, "curl_easy_perform() failed: %s\n",
  46.                 curl_easy_strerror(res));
  47.  
  48.         /* Always cleanup */
  49.         curl_easy_cleanup(curl);
  50.     }
  51.  
  52.     return (int)res;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement