diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-09-25 13:49:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-09-25 13:49:13 +0100 |
| commit | d087368dc0dcd6026b3a967f00f145feb701dd0e (patch) | |
| tree | f44d2bb828c3572f0bbb3a74ec4e2f497d54168c /src/lib/util.cc | |
| parent | 5909b9672821c1d5ea974761316dc0f3df558349 (diff) | |
Basic email of KDMs works.
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 739a327d6..6746b4773 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -54,7 +54,6 @@ extern "C" { #include <libpostproc/postprocess.h> #include <libavutil/pixfmt.h> } -#include <curl/curl.h> #include "util.h" #include "exceptions.h" #include "scaler.h" @@ -817,53 +816,3 @@ tidy_for_filename (string f) return t; } - -struct EmailState -{ - string message; - int done; -}; - -static size_t -send_email_function (void* ptr, size_t size, size_t nmemb, void* userdata) -{ - EmailState* state = reinterpret_cast<EmailState*> (userdata); - - int const now = min (size * nmemb, state->message.length() - state->done); - - memcpy (ptr, state->message.c_str() + state->done, now); - state->done += now; - - return now; -} - -bool -send_email (string from, string to, string message) -{ - CURL* curl = curl_easy_init (); - if (!curl) { - return true; - } - - string const url = "smtp://" + Config::instance()->mail_server(); - - curl_easy_setopt (curl, CURLOPT_URL, url.c_str ()); - curl_easy_setopt (curl, CURLOPT_MAIL_FROM, from.c_str ()); - struct curl_slist* recipients = 0; - recipients = curl_slist_append (recipients, to.c_str ()); - curl_easy_setopt (curl, CURLOPT_READFUNCTION, send_email_function); - - EmailState state; - state.message = message; - state.done = 0; - curl_easy_setopt (curl, CURLOPT_READDATA, &state); - - if (curl_easy_perform (curl) != CURLE_OK) { - return true; - } - - curl_slist_free_all (recipients); - curl_easy_cleanup (curl); - - return false; -} |
