Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at http://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
- #include <stddef.h>
- #include <stdlib.h>
- #include <curl/curl.h>
- const char* cacert_filepath = "";
- int smtp_port = 25;
- const char* smtp_host = "";
- const char* smtp_login = "";
- const char* smtp_password = "";
- const char* sender_email = "";
- const char* recipient = "";
- FILE* f = fopen("test.eml","rb");
- int main(void)
- {
- curl_global_init(CURL_GLOBAL_ALL );
- CURL* curl_ptr = curl_easy_init();
- if(!curl_ptr)
- return 1;
- curl_easy_setopt(curl_ptr,CURLOPT_TIMEOUT,120);
- curl_easy_setopt(curl_ptr, CURLOPT_USE_SSL, CURLUSESSL_ALL);
- curl_easy_setopt(curl_ptr, CURLOPT_SSL_VERIFYPEER,1);
- curl_easy_setopt(curl_ptr, CURLOPT_SSL_VERIFYHOST, 2);
- curl_easy_setopt(curl_ptr, CURLOPT_CAINFO, cacert_filepath);
- curl_easy_setopt(curl_ptr, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT);
- curl_easy_setopt(curl_ptr, CURLOPT_SSL_SESSIONID_CACHE, 1);
- curl_easy_setopt(curl_ptr, CURLOPT_URL, smtp_host);
- curl_easy_setopt(curl_ptr, CURLOPT_PORT, smtp_port);
- curl_easy_setopt(curl_ptr, CURLOPT_USERNAME, smtp_login);
- curl_easy_setopt(curl_ptr, CURLOPT_PASSWORD, smtp_password);
- curl_easy_setopt(curl_ptr, CURLOPT_MAIL_FROM, sender_email);
- struct curl_slist* rcpt_list = NULL;
- rcpt_list = curl_slist_append(rcpt_list, recipient);
- curl_easy_setopt(curl_ptr, CURLOPT_MAIL_RCPT, rcpt_list);
- curl_easy_setopt(curl_ptr, CURLOPT_READDATA, f);
- CURLcode error_code = curl_easy_perform(curl_ptr);
- if(error_code != CURLE_OK)
- return 1;
- curl_slist_free_all(rcpt_list);
- curl_easy_cleanup(curl_ptr);
- curl_global_cleanup();
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement