Fix erroneous thread affinity log message.
[dcpomatic.git] / src / lib / cinema_kdms.cc
index 2b1d457aa1ad04614fa7d378207b1fde1584c38f..318eebe3996af238156e3ce0e7c9b4bed9376faa 100644 (file)
@@ -124,6 +124,10 @@ CinemaKDMs::email (
 {
        Config* config = Config::instance ();
 
+       if (config->mail_server().empty()) {
+               throw NetworkError (_("No mail server configured in preferences"));
+       }
+
        BOOST_FOREACH (CinemaKDMs const & i, cinema_kdms) {
 
                boost::filesystem::path zip_file = boost::filesystem::temp_directory_path ();
@@ -154,8 +158,8 @@ CinemaKDMs::email (
 
                Emailer email (config->kdm_from(), i.cinema->emails, subject, body);
 
-               if (!config->kdm_cc().empty ()) {
-                       email.add_cc (config->kdm_cc ());
+               BOOST_FOREACH (string i, config->kdm_cc()) {
+                       email.add_cc (i);
                }
                if (!config->kdm_bcc().empty ()) {
                        email.add_bcc (config->kdm_bcc ());
@@ -165,9 +169,23 @@ CinemaKDMs::email (
                email.add_attachment (zip_file, name, "application/zip");
 
                Config* c = Config::instance ();
-               email.send (c->mail_server(), c->mail_port(), c->mail_user(), c->mail_password());
+
+               try {
+                       email.send (c->mail_server(), c->mail_port(), c->mail_user(), c->mail_password());
+               } catch (...) {
+                       if (log) {
+                               log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL);
+                               log->log (email.email(), LogEntry::TYPE_DEBUG_EMAIL);
+                               log->log ("Email session follows", LogEntry::TYPE_DEBUG_EMAIL);
+                               log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL);
+                       }
+                       throw;
+               }
 
                if (log) {
+                       log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL);
+                       log->log (email.email(), LogEntry::TYPE_DEBUG_EMAIL);
+                       log->log ("Email session follows", LogEntry::TYPE_DEBUG_EMAIL);
                        log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL);
                }
        }