Browse Source

[Web] Optional HTML in system mails (#3879)

* HTML in system mails

* Update functions.inc.php

* Update functions.inc.php

Co-authored-by: André Peters <andre.peters@debinux.de>
Balázs Dura-Kovács 4 years ago
parent
commit
dd1b25fa61
3 changed files with 18 additions and 1 deletions
  1. 7 0
      data/web/admin.php
  2. 8 1
      data/web/inc/functions.inc.php
  3. 3 0
      data/web/lang/lang.en.json

+ 7 - 0
data/web/admin.php

@@ -1278,6 +1278,13 @@ if (!isset($_SESSION['gal']) && $license_cache = $redis->Get('LICENSE_STATUS_CAC
               <textarea class="form-control" rows="10" name="mass_text" id="mass_text" required></textarea>
             </div>
           </div>
+          <div class="form-group">
+            <label class="control-label col-sm-2" for="mass_html"><?=$lang['admin']['html'];?> (<?=$lang['admin']['optional'];?>):</label>
+            <div class="col-sm-10">
+              <textarea class="form-control" rows="10" name="mass_html" id="mass_html"></textarea>
+              <p class="small">↪ <a target="_blank" href="https://templates.mailchimp.com/resources/html-to-text/"><?=$lang['admin']['convert_html_to_text'];?></a></p>
+            </div>
+          </div>
           <div class="form-group">
             <div class="col-sm-offset-2 col-sm-10">
               <label>

+ 8 - 1
data/web/inc/functions.inc.php

@@ -143,6 +143,7 @@ function sys_mail($_data) {
   $mailboxes = array();
   $mass_from = $_data['mass_from'];
   $mass_text = $_data['mass_text'];
+  $mass_html = $_data['mass_html'];
   $mass_subject = $_data['mass_subject'];
   if (!filter_var($mass_from, FILTER_VALIDATE_EMAIL)) {
 		$_SESSION['return'][] =  array(
@@ -202,7 +203,13 @@ function sys_mail($_data) {
     $mail->setFrom($mass_from);
     $mail->Subject = $mass_subject;
     $mail->CharSet ="UTF-8";
-    $mail->Body = $mass_text;
+    if (!empty($mass_html)) {
+      $mail->Body = $mass_html;
+      $mail->AltBody = $mass_text;
+    }
+    else {
+      $mail->Body = $mass_text;
+    }
     $mail->XMailer = 'MooMassMail';
     foreach ($rcpts as $rcpt) {
       $mail->AddAddress($rcpt);

+ 3 - 0
data/web/lang/lang.en.json

@@ -139,6 +139,7 @@
         "ban_list_info": "See a list of banned IPs below: <b>network (remaining ban time) - [actions]</b>.<br />IPs queued to be unbanned will be removed from the active ban list within a few seconds.<br />Red labels indicate active permanent bans by blacklisting.",
         "change_logo": "Change logo",
         "configuration": "Configuration",
+        "convert_html_to_text": "Convert HTML to plain text",
         "credentials_transport_warning": "<b>Warning</b>: Adding a new transport map entry will update the credentials for all entries with a matching nexthop column.",
         "customer_id": "Customer ID",
         "customize": "Customize",
@@ -190,6 +191,7 @@
         "hash_remove_info": "Removing a ratelimit hash (if still existing) will reset its counter completely.<br>\r\n  Each hash is indicated by an individual color.",
         "help_text": "Override help text below login mask (HTML allowed)",
         "host": "Host",
+        "html": "HTML",
         "import": "Import",
         "import_private_key": "Import private key",
         "in_use_by": "In use by",
@@ -218,6 +220,7 @@
         "oauth2_redirect_uri": "Redirect URI",
         "oauth2_renew_secret": "Generate new client secret",
         "oauth2_revoke_tokens": "Revoke all client tokens",
+        "optional": "optional",
         "password": "Password",
         "password_repeat": "Confirmation password (repeat)",
         "priority": "Priority",