diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-05-06 00:55:18 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-06-03 22:26:16 +0200 |
| commit | cacb0750b9e6efbefa5ffa33a0df9552db5483db (patch) | |
| tree | 98deb6fb61004f9c1dadca65bf3f74c3a15929ad /src/lib/kdm_with_metadata.cc | |
| parent | 2bdee4f8e7712c50125b296a50c967101e619f94 (diff) | |
Allow sending KDMs to more emails (#2244).
Diffstat (limited to 'src/lib/kdm_with_metadata.cc')
| -rw-r--r-- | src/lib/kdm_with_metadata.cc | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index a826327ca..5c1ab0aa6 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -38,6 +38,7 @@ using std::function; using std::list; using std::shared_ptr; using std::string; +using std::vector; using boost::optional; @@ -201,7 +202,8 @@ send_emails ( list<list<KDMWithMetadataPtr>> kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - string cpl_name + string cpl_name, + vector<string> extra_addresses ) { auto config = Config::instance (); @@ -255,22 +257,38 @@ send_emails ( email.add_attachment (zip_file, container_name_format.get(first->name_values(), ".zip"), "application/zip"); + auto log_details = [](Emailer& email) { + dcpomatic_log->log("Email content follows", LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log(email.email(), LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log("Email session follows", LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log(email.notes(), LogEntry::TYPE_DEBUG_EMAIL); + }; + try { email.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password()); } catch (...) { boost::filesystem::remove (zip_file); - dcpomatic_log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log (email.email(), LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log ("Email session follows", LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL); + log_details (email); throw; } - boost::filesystem::remove (zip_file); + log_details (email); - dcpomatic_log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log (email.email(), LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log ("Email session follows", LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log (email.notes(), LogEntry::TYPE_DEBUG_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); } } |
