Advertisement
Momir

Mejl slanje gmail

Feb 26th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <curl/curl.h>
  4.  
  5. int main(void)
  6. {
  7.     CURL* curl;
  8.     CURLcode res = CURLE_OK;
  9.  
  10.  
  11.     curl = curl_easy_init();
  12.     if (curl) {
  13.         struct curl_slist* recipients = NULL;
  14.         curl_mime* mime;
  15.         curl_mimepart* part;
  16.         const char** cpp;
  17.  
  18.         curl_easy_setopt(curl, CURLOPT_URL, "smtps://smtp.gmail.com:465");
  19.         curl_easy_setopt(curl, CURLOPT_USERNAME, "ime.prezime@gmail.com");
  20.         curl_easy_setopt(curl, CURLOPT_PASSWORD, "Sifra");
  21.         recipients = curl_slist_append(recipients, "ime.prezime@gmail.com");
  22.         curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
  23.  
  24.         mime = curl_mime_init(curl);
  25.         part = curl_mime_addpart(mime);
  26.         curl_mime_filedata(part, "D:\\jebise.txt");
  27.         curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
  28.  
  29.         for (long long int i = 1; 1; i++) {
  30.             res = curl_easy_perform(curl);
  31.             Sleep(1000);
  32.  
  33.             if (res != CURLE_OK)
  34.                 fprintf(stderr, "Nije poslato, error: %s\n", curl_easy_strerror(res));
  35.             else
  36.                 fprintf(stderr, "%d\n", i);
  37.         }
  38.  
  39.         curl_slist_free_all(recipients);
  40.         curl_easy_cleanup(curl);
  41.         curl_mime_free(mime);
  42.     }
  43.  
  44.     return (int)res;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement