2 Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "send_notification_email_job.h"
23 #include "exceptions.h"
26 #include "compose.hpp"
32 using std::shared_ptr;
35 /** @param body Email body */
36 SendNotificationEmailJob::SendNotificationEmailJob (string body)
37 : Job (shared_ptr<Film>())
44 SendNotificationEmailJob::~SendNotificationEmailJob ()
51 SendNotificationEmailJob::name () const
53 return _("Email notification");
58 SendNotificationEmailJob::json_name () const
60 return N_("send_notification_email");
65 SendNotificationEmailJob::run ()
67 auto config = Config::instance ();
69 if (config->mail_server().empty()) {
70 throw MissingConfigurationError(_("No outgoing mail server configured in the Email tab of preferences"));
73 set_progress_unknown ();
74 Email email(config->notification_from(), { config->notification_to() }, config->notification_subject(), _body);
75 for (auto i: config->notification_cc()) {
78 if (!config->notification_bcc().empty()) {
79 email.add_bcc (config->notification_bcc());
82 email.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
85 set_state (FINISHED_OK);