诸暨麻将添加redis
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

88 lines
3.5 KiB

  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at http://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. ***************************************************************************/
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <curl/curl.h>
  25. int main(void)
  26. {
  27. CURL *curl;
  28. CURLcode res;
  29. struct curl_slist *recipients = NULL;
  30. /* value for envelope reverse-path */
  31. static const char *from = "<bradh@example.com>";
  32. /* this becomes the envelope forward-path */
  33. static const char *to = "<bradh@example.net>";
  34. curl = curl_easy_init();
  35. if(curl) {
  36. /* this is the URL for your mailserver - you can also use an smtps:// URL
  37. * here */
  38. curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.net.");
  39. /* Note that this option isn't strictly required, omitting it will result in
  40. * libcurl will sent the MAIL FROM command with no sender data. All
  41. * autoresponses should have an empty reverse-path, and should be directed
  42. * to the address in the reverse-path which triggered them. Otherwise, they
  43. * could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
  44. */
  45. curl_easy_setopt(curl, CURLOPT_MAIL_FROM, from);
  46. /* Note that the CURLOPT_MAIL_RCPT takes a list, not a char array. */
  47. recipients = curl_slist_append(recipients, to);
  48. curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
  49. /* You provide the payload (headers and the body of the message) as the
  50. * "data" element. There are two choices, either:
  51. * - provide a callback function and specify the function name using the
  52. * CURLOPT_READFUNCTION option; or
  53. * - just provide a FILE pointer that can be used to read the data from.
  54. * The easiest case is just to read from standard input, (which is available
  55. * as a FILE pointer) as shown here.
  56. */
  57. curl_easy_setopt(curl, CURLOPT_READDATA, stdin);
  58. /* send the message (including headers) */
  59. res = curl_easy_perform(curl);
  60. /* Check for errors */
  61. if(res != CURLE_OK)
  62. fprintf(stderr, "curl_easy_perform() failed: %s\n",
  63. curl_easy_strerror(res));
  64. /* free the list of recipients */
  65. curl_slist_free_all(recipients);
  66. /* curl won't send the QUIT command until you call cleanup, so you should be
  67. * able to re-use this connection for additional messages (setting
  68. * CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and calling
  69. * curl_easy_perform() again. It may not be a good idea to keep the
  70. * connection open for a very long time though (more than a few minutes may
  71. * result in the server timing out the connection), and you do want to clean
  72. * up in the end.
  73. */
  74. curl_easy_cleanup(curl);
  75. }
  76. return 0;
  77. }