diff --git a/docker/docker-compose-dev.yml b/docker/docker-compose-dev.yml
index 24327992..7c2c8fb8 100644
--- a/docker/docker-compose-dev.yml
+++ b/docker/docker-compose-dev.yml
@@ -12,7 +12,7 @@ services:
args:
env: devel
fqdn: motionui-dev.localhost
- restart: unless-stopped
+ restart: always
ports:
- "8888:8080"
volumes:
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index a5227224..588f6c25 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -11,7 +11,7 @@ services:
args:
env: prod
fqdn: motionui.example.com
- restart: unless-stopped
+ restart: always
ports:
- "8080:8080"
volumes:
diff --git a/www/config/properties.php b/www/config/properties.php
index 7b0c373c..b28a6c76 100644
--- a/www/config/properties.php
+++ b/www/config/properties.php
@@ -2,7 +2,7 @@
$config = array(
'project_name' => 'motion-UI',
'project_dir_name' => 'motionui',
- 'project_logo' => 'https://raw.githubusercontent.com/lbr38/motion-UI/main/www/public//assets/images/motion.png',
+ 'project_logo' => 'https://raw.githubusercontent.com/lbr38/motion-UI/main/www/public/assets/images/motion.png',
'project_git_repo' => 'https://github.com/lbr38/motion-UI',
'project_git_repo_raw' => 'https://raw.githubusercontent.com/lbr38/motion-UI/main',
'project_update_doc_url' => 'https://github.com/lbr38/motion-UI/wiki/01.-Installation-and-update#update-motion-ui'
diff --git a/www/controllers/Mail.php b/www/controllers/Mail.php
index 3c80e519..52a49698 100644
--- a/www/controllers/Mail.php
+++ b/www/controllers/Mail.php
@@ -11,7 +11,7 @@
class Mail
{
- public function __construct(string|array $to, string $subject, string $content, string $link = null, string $linkName = 'Click here', string $attachmentFilePath = null)
+ public function __construct(string $to, string $subject, string $content, string $link = null, string $linkName = 'Click here', string $attachmentFilePath = null)
{
if (empty($to)) {
throw new \Exception('Error: mail recipient cannot be empty');
@@ -23,13 +23,16 @@ public function __construct(string|array $to, string $subject, string $content,
throw new \Exception('Error: mail message cannot be empty');
}
- if (is_array($to)) {
- $to = implode(',', $to);
+ /**
+ * if there is a , in the $to string, it means there are multiple recipients
+ */
+ if (strpos($to, ',') !== false) {
+ $to = explode(',', $to);
}
/**
* HTML message template
- * Powered by stripo.email
+ * Powered by MJML
*/
ob_start();
include(ROOT . '/templates/mail/mail.template.html.php');
@@ -43,7 +46,15 @@ public function __construct(string|array $to, string $subject, string $content,
try {
// Recipients
$mail->setFrom('noreply@' . WWW_HOSTNAME, PROJECT_NAME);
- $mail->addAddress($to);
+
+ if (is_array($to)) {
+ foreach ($to as $recipient) {
+ $mail->addAddress($recipient);
+ }
+ } else {
+ $mail->addAddress($to);
+ }
+
$mail->addReplyTo('noreply@' . WWW_HOSTNAME, PROJECT_NAME);
// Attachments
@@ -58,7 +69,7 @@ public function __construct(string|array $to, string $subject, string $content,
$mail->send();
} catch (Exception $e) {
- echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
+ throw new Exception('Error: mail could not be sent. Mailer Error: ' . $mail->ErrorInfo);
}
}
}
diff --git a/www/controllers/ajax/motion.php b/www/controllers/ajax/motion.php
index 9ef21a76..fa9c7236 100644
--- a/www/controllers/ajax/motion.php
+++ b/www/controllers/ajax/motion.php
@@ -1,5 +1,18 @@
getMessage());
+ }
+
+ response(HTTP_OK, 'Email sent');
+}
+
/*
* Enable / disable alerts
*/
diff --git a/www/public/resources/js/motion.js b/www/public/resources/js/motion.js
index 733d6730..69ea532d 100644
--- a/www/public/resources/js/motion.js
+++ b/www/public/resources/js/motion.js
@@ -119,6 +119,14 @@ $(document).on('click','#disable-alert-btn',function () {
enableAlert('disabled');
});
+/**
+ * Event: send a test email
+ */
+$(document).on('click','#send-test-email-btn',function () {
+ var mailRecipient = $(this).attr('mail-recipient');
+ sendTestEmail(mailRecipient);
+});
+
/**
* Event: select stats dates
*/
@@ -665,6 +673,31 @@ function enableAlert(status)
});
}
+/**
+ * Ajax: send a test email
+ */
+function sendTestEmail(mailRecipient)
+{
+ $.ajax({
+ type: "POST",
+ url: "/ajax/controller.php",
+ data: {
+ controller: "motion",
+ action: "sendTestEmail",
+ mailRecipient: mailRecipient
+ },
+ dataType: "json",
+ success: function (data, textStatus, jqXHR) {
+ jsonValue = jQuery.parseJSON(jqXHR.responseText);
+ printAlert(jsonValue.message, 'success');
+ },
+ error: function (jqXHR, textStatus, thrownError) {
+ jsonValue = jQuery.parseJSON(jqXHR.responseText);
+ printAlert(jsonValue.message, 'error');
+ },
+ });
+}
+
/**
* Ajax: configure alerts
* @param {*} mondayStart
diff --git a/www/public/resources/styles/common.css b/www/public/resources/styles/common.css
index 1314f277..baffbcc3 100644
--- a/www/public/resources/styles/common.css
+++ b/www/public/resources/styles/common.css
@@ -1,5 +1,5 @@
/**
- * v1.2
+ * v1.3
*/
/**
diff --git a/www/templates/mail/mail.template.html copy.php b/www/templates/mail/mail.template.html copy.php
new file mode 100644
index 00000000..70d99b4e
--- /dev/null
+++ b/www/templates/mail/mail.template.html copy.php
@@ -0,0 +1,411 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+= PROJECT_NAME ?> - release version = VERSION ?> Github |
+
+ |
+
+ |
+
+ |
+
+
+ |
+
+
+
+
+
\ No newline at end of file
diff --git a/www/templates/mail/mail.template.html.php b/www/templates/mail/mail.template.html.php
index 70d99b4e..721ae3ad 100644
--- a/www/templates/mail/mail.template.html.php
+++ b/www/templates/mail/mail.template.html.php
@@ -1,411 +1,210 @@
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
- |
-
-
-
-
-
-
-
-
-= PROJECT_NAME ?> - release version = VERSION ?> Github |
-
- |
-
- |
-
- |
-
-
- |
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = $content ?>
+ |
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = PROJECT_NAME ?> - release version = VERSION ?> Github
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/www/views/includes/panels/motion/alert.inc.php b/www/views/includes/panels/motion/alert.inc.php
index 1132e85e..50351787 100644
--- a/www/views/includes/panels/motion/alert.inc.php
+++ b/www/views/includes/panels/motion/alert.inc.php
@@ -59,6 +59,12 @@
+';
+ echo 'Send test email';
+} ?>
+