Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 22nd, 2011  |  syntax: C++  |  size: 6.38 KB  |  views: 69  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Test.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include <iostream>
  5. #include <cstdio>
  6. #define  WINVER      0x0500
  7. #define _WIN32_WINNT 0x0500
  8. #define  PSAPI_VERSION    1
  9. #include <windows.h>
  10. #include <tchar.h>
  11. #include <psapi.h>
  12. #include <sddl.h>
  13. #include <fstream>
  14. #include <string.h>
  15. #include <string>
  16. #include <curl\curl.h>;
  17. using namespace std;
  18.  
  19. #define FROM    "<trollger2011@wp.pl>"
  20. #define TO      "<trollger2011@gmail.com>"
  21. #define CC      "<jshym1@gmail.com>"
  22.  
  23. static const char *payload_text[]={
  24.   "Date: Mon, 29 Nov 2010 21:54:29 +1100\n",
  25.   "To: " TO "\n",
  26.   "From: " FROM "(Example User)\n",
  27.   "Cc: " CC "(Another example User)\n",
  28.   "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\n",
  29.   "Subject: SMTP TLS example message\n",
  30.   "\n", /* empty line to divide headers from body, see RFC5322 */
  31.   "The body of the message starts here.\n",
  32.   "\n",
  33.   "It could be a lot of lines, could DZIWKOOO hatever.\n",
  34.   "Check RFC5322.\n",
  35.   NULL
  36. };
  37.  
  38. struct upload_status {
  39.   int lines_read;
  40. };
  41.  
  42. MY DECLARED FUNCTIONS
  43. int email();
  44. static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp);
  45.  
  46. int main(){
  47.         MY PROGRAM CODE
  48.                 email();
  49.         system("PAUSE");
  50.     return 0;
  51. }
  52. /* *************************************** */
  53. /* *************************************** */
  54. MY PROGRAM CODE
  55. /* *************************************** */
  56. /* *************************************** */
  57. /* This is a simple example showing how to send mail using libcurl's SMTP
  58.  * capabilities. It builds on the simplesmtp.c example, adding some
  59.  * authentication and transport security.
  60.  */
  61.  
  62.  
  63.  
  64. static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp)
  65. {
  66.   struct upload_status *upload_ctx = (struct upload_status *)userp;
  67.   const char *data;
  68.  
  69.   if ((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
  70.     return 0;
  71.   }
  72.  
  73.   data = payload_text[upload_ctx->lines_read];
  74.  
  75.   if (data) {
  76.     size_t len = strlen(data);
  77.     memcpy(ptr, data, len);
  78.     upload_ctx->lines_read ++;
  79.     return len;
  80.   }
  81.   return 0;
  82. }
  83.  
  84.  
  85. int email()
  86. {
  87.   CURL *curl;
  88.   CURLcode res;
  89.   struct curl_slist *recipients = NULL;
  90.   struct upload_status upload_ctx;
  91.  
  92.   upload_ctx.lines_read = 0;
  93.  
  94.   curl = curl_easy_init();
  95.   if (curl) {
  96.     /* This is the URL for your mailserver. Note the use of port 587 here,
  97.      * instead of the normal SMTP port (25). Port 587 is commonly used for
  98.      * secure mail submission (see RFC4403), but you should use whatever
  99.      * matches your server configuration. */
  100.     curl_easy_setopt(curl, CURLOPT_URL, "smtp://smtp.wp.pl:465");
  101.  
  102.     /* In this example, we'll start with a plain text connection, and upgrade
  103.      * to Transport Layer Security (TLS) using the STARTTLS command. Be careful
  104.      * of using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer
  105.      * will continue anyway - see the security discussion in the libcurl
  106.      * tutorial for more details. */
  107.     curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
  108.  
  109.     /* If your server doesn't have a valid certificate, then you can disable
  110.      * part of the Transport Layer Security protection by setting the
  111.      * CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to 0 (false).
  112.      *   curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
  113.      *   curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
  114.      * That is, in general, a bad idea. It is still better than sending your
  115.      * authentication details in plain text though.
  116.      * Instead, you should get the issuer certificate (or the host certificate
  117.      * if the certificate is self-signed) and add it to the set of certificates
  118.      * that are known to libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH. See
  119.      * docs/SSLCERTS for more information.
  120.    
  121.     curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
  122.   */
  123.     /* A common reason for requiring transport security is to protect
  124.      * authentication details (user names and passwords) from being "snooped"
  125.      * on the network. Here is how the user name and password are provided: */
  126.     curl_easy_setopt(curl, CURLOPT_USERNAME, "LOGIN");
  127.     curl_easy_setopt(curl, CURLOPT_PASSWORD, "PASSWORD");
  128.  
  129.     /* value for envelope reverse-path */
  130.     curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
  131.     /* Add two recipients, in this particular case they correspond to the
  132.      * To: and Cc: addressees in the header, but they could be any kind of
  133.      * recipient. */
  134.     recipients = curl_slist_append(recipients, TO);
  135.     recipients = curl_slist_append(recipients, CC);
  136.     curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
  137.  
  138.     /* In this case, we're using a callback function to specify the data. You
  139.      * could just use the CURLOPT_READDATA option to specify a FILE pointer to
  140.      * read from.
  141.      */
  142.     curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
  143.     curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
  144.  
  145.     /* Since the traffic will be encrypted, it is very useful to turn on debug
  146.      * information within libcurl to see what is happening during the transfer.
  147.      */
  148.     curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
  149.  
  150.     /* send the message (including headers) */
  151.     res = curl_easy_perform(curl);
  152.  
  153.     /* free the list of recipients and clean up */
  154.     curl_slist_free_all(recipients);
  155.     curl_easy_cleanup(curl);
  156.   }
  157.   return 0;
  158. }
  159.  
  160.         ntdll.dll!7de9e39e()    
  161.         [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
  162. >       msvcr100.dll!free(void * pBlock)  Line 51       C
  163.         Test.exe!Curl_cache_addr(SessionHandle * data, Curl_addrinfo * addr, const char * hostname, int port)  Line 373 + 0xc bytes     C
  164.         0018fdf8()    
  165.         msvcr100.dll!free(void * pBlock)  Line 51       C
  166.         Test.exe!destroy_async_data(Curl_async * async)  Line 334 + 0xe bytes   C
  167.         Test.exe!Curl_resolver_wait_resolv(connectdata * conn, Curl_dns_entry * * entry)  Line 516 + 0xf bytes  C
  168.         Test.exe!connect_host(SessionHandle * data, connectdata * * conn)  Line 1989 + 0xd bytes        C
  169.         Test.exe!Curl_do_perform(SessionHandle * data)  Line 2122 + 0xd bytes   C
  170.         Test.exe!Curl_perform(SessionHandle * data)  Line 2268 + 0x9 bytes      C
  171.         Test.exe!curl_easy_perform(void * curl)  Line 553 + 0x9 bytes   C
  172.         Test.exe!email()  Line 379      C++
  173.         Test.exe!main()  Line 71        C++
  174.         msvcr100.dll!_initterm(void (void)* * pfbegin, void (void)* * pfend)  Line 873  C