NobGit
public nobgit read

NobMail

Based on mailcow: dockerized

Languages

Repository composition by tracked source files.

PHP
PHP 49% JavaScript 35% HTML 9% CSS 4% Shell 2% Python 1% Lua 0% Perl 0% Ruby 0% SCSS 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git

Commit

[Web] check if mbox exists before excluding it from domain wide footer

7b7798e8
FreddleSpl0it <[email protected]> 2 years, 8 months ago
data/web/inc/functions.mailbox.inc.php | 50 ++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 20 deletions(-)

Diff

diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index 7c2955f6..e965feaf 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -3408,6 +3408,36 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
             $domains = $_data['domains'];
           }
 
+          $footers = array();
+          $footers['html'] = isset($_data['html']) ? $_data['html'] : '';
+          $footers['plain'] = isset($_data['plain']) ? $_data['plain'] : '';
+          $footers['mbox_exclude'] = array();
+          if (isset($_data["mbox_exclude"])){
+            if (!is_array($_data["mbox_exclude"])) {
+              $_data["mbox_exclude"] = array($_data["mbox_exclude"]);
+            }
+            foreach ($_data["mbox_exclude"] as $mailbox) {
+              if (!filter_var($mailbox, FILTER_VALIDATE_EMAIL)) {
+                $_SESSION['return'][] = array(
+                  'type' => 'danger',
+                  'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
+                  'msg' => array('username_invalid', $mailbox)
+                );
+                continue;
+              }
+              $is_now = mailbox('get', 'mailbox_details', $mailbox);            
+              if(empty($is_now)){
+                $_SESSION['return'][] = array(
+                  'type' => 'danger',
+                  'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
+                  'msg' => array('username_invalid', $mailbox)
+                );
+                continue;
+              }
+              
+              array_push($footers['mbox_exclude'], $mailbox);
+            }
+          }
           foreach ($domains as $domain) {
             $domain = idn_to_ascii(strtolower(trim($domain)), 0, INTL_IDNA_VARIANT_UTS46);
             if (!is_valid_domain_name($domain)) {
@@ -3427,26 +3457,6 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
               return false;
             }
 
-            $footers = array();
-            $footers['html'] = isset($_data['html']) ? $_data['html'] : '';
-            $footers['plain'] = isset($_data['plain']) ? $_data['plain'] : '';
-            $footers['mbox_exclude'] = array();
-            if (isset($_data["mbox_exclude"])){
-              if (!is_array($_data["mbox_exclude"])) {
-                $_data["mbox_exclude"] = array($_data["mbox_exclude"]);
-              }
-              foreach ($_data["mbox_exclude"] as $mailbox) {
-                if (!filter_var($mailbox, FILTER_VALIDATE_EMAIL)) {
-                  $_SESSION['return'][] = array(
-                    'type' => 'danger',
-                    'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
-                    'msg' => array('username_invalid', $mailbox)
-                  );
-                } else {
-                  array_push($footers['mbox_exclude'], $mailbox);
-                }
-              }
-            }
             try {
               $stmt = $pdo->prepare("DELETE FROM `domain_wide_footer` WHERE `domain`= :domain");
               $stmt->execute(array(':domain' => $domain));