From 09e864110e299b1c9c78ee835fb77dfad6f6bcc5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 4 Dec 2015 02:14:07 +0000 Subject: [PATCH] Fix nonfunctional send-problem-report. --- ChangeLog | 4 ++++ src/lib/cinema_kdms.cc | 4 +++- src/lib/emailer.cc | 16 ++++++---------- src/lib/emailer.h | 2 +- src/lib/send_problem_report_job.cc | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index bea02a8b7..7aee3f561 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-12-04 Carl Hetherington + + * Fix non-functional send-problem-report. + 2015-12-03 Carl Hetherington * Version 2.6.2 released. diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index d95e02854..2b1d457aa 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -163,7 +163,9 @@ CinemaKDMs::email ( string const name = tidy_for_filename(i.cinema->name) + "_" + tidy_for_filename(film_name) + ".zip"; email.add_attachment (zip_file, name, "application/zip"); - email.send (); + + Config* c = Config::instance (); + email.send (c->mail_server(), c->mail_port(), c->mail_user(), c->mail_password()); if (log) { log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL); diff --git a/src/lib/emailer.cc b/src/lib/emailer.cc index c20cc897d..c7f1b9053 100644 --- a/src/lib/emailer.cc +++ b/src/lib/emailer.cc @@ -90,7 +90,7 @@ Emailer::get_data (void* ptr, size_t size, size_t nmemb) } void -Emailer::send () +Emailer::send (string server, int port, string user, string password) { char date_buffer[32]; time_t now = time (0); @@ -172,17 +172,13 @@ Emailer::send () throw NetworkError ("Could not initialise libcurl"); } - curl_easy_setopt (curl, CURLOPT_URL, String::compose ( - "smtp://%1:%2", - Config::instance()->mail_server().c_str(), - Config::instance()->mail_port() - ).c_str()); + curl_easy_setopt (curl, CURLOPT_URL, String::compose ("smtp://%1:%2", server.c_str(), port).c_str()); - if (!Config::instance()->mail_user().empty ()) { - curl_easy_setopt (curl, CURLOPT_USERNAME, Config::instance()->mail_user().c_str()); + if (!user.empty ()) { + curl_easy_setopt (curl, CURLOPT_USERNAME, user.c_str ()); } - if (!Config::instance()->mail_password().empty ()) { - curl_easy_setopt (curl, CURLOPT_PASSWORD, Config::instance()->mail_password().c_str()); + if (!password.empty ()) { + curl_easy_setopt (curl, CURLOPT_PASSWORD, password.c_str()); } curl_easy_setopt (curl, CURLOPT_MAIL_FROM, _from.c_str()); diff --git a/src/lib/emailer.h b/src/lib/emailer.h index 8ec983f43..9d799c81c 100644 --- a/src/lib/emailer.h +++ b/src/lib/emailer.h @@ -29,7 +29,7 @@ public: void add_bcc (std::string bcc); void add_attachment (boost::filesystem::path file, std::string name, std::string mime_type); - void send (); + void send (std::string server, int port, std::string user = "", std::string password = ""); std::string notes () const { return _notes; diff --git a/src/lib/send_problem_report_job.cc b/src/lib/send_problem_report_job.cc index 803e655a6..139bdb81c 100644 --- a/src/lib/send_problem_report_job.cc +++ b/src/lib/send_problem_report_job.cc @@ -85,7 +85,7 @@ SendProblemReportJob::run () to.push_back ("carl@dcpomatic.com"); Emailer emailer (_from, to, "DCP-o-matic problem report", body); - emailer.send (); + emailer.send ("main.carlh.net", 2525); set_progress (1); set_state (FINISHED_OK); -- 2.30.2