X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fkdm_with_metadata.cc;h=5cbadc911a0dfba290dec7661f575688ad68e0c5;hb=0c766528070eadd3d044255a3e4dfde5a85707b5;hp=5c1ab0aa6fe2e3b2978073d918dedc35b9664969;hpb=cacb0750b9e6efbefa5ffa33a0df9552db5483db;p=dcpomatic.git diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index 5c1ab0aa6..5cbadc911 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -153,8 +153,8 @@ write_directories ( if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { boost::filesystem::create_directories (path); write_files(kdm, path, filename_format, confirm_overwrite); + written += kdm.size(); } - written += kdm.size(); } return written; @@ -212,14 +212,14 @@ send_emails ( throw NetworkError (_("No mail server configured in preferences")); } + if (config->kdm_from().empty()) { + throw NetworkError(_("No KDM from address configured in preferences")); + } + for (auto const& kdms_for_cinema: kdms) { auto first = kdms_for_cinema.front(); - if (first->emails().empty()) { - continue; - } - auto zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); boost::filesystem::create_directories (zip_file); zip_file /= container_name_format.get(first->name_values(), ".zip"); @@ -246,7 +246,18 @@ send_emails ( } boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2)); - Emailer email (config->kdm_from(), first->emails(), subject, body); + auto emails = first->emails(); + std::copy(extra_addresses.begin(), extra_addresses.end(), std::back_inserter(emails)); + if (emails.empty()) { + continue; + } + + Emailer email (config->kdm_from(), { emails.front() }, subject, body); + + /* Use CC for the second and subsequent email addresses, so we seem less spammy (#2310) */ + for (auto cc = std::next(emails.begin()); cc != emails.end(); ++cc) { + email.add_cc(*cc); + } for (auto cc: config->kdm_cc()) { email.add_cc (cc); @@ -274,21 +285,6 @@ send_emails ( log_details (email); - for (auto extra: extra_addresses) { - Emailer email (config->kdm_from(), { extra }, subject, body); - email.add_attachment (zip_file, container_name_format.get(first->name_values(), ".zip"), "application/zip"); - - try { - email.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password()); - } catch (...) { - boost::filesystem::remove (zip_file); - log_details (email); - throw; - } - - log_details (email); - } - boost::filesystem::remove (zip_file); } }