diff --git a/data/Dockerfiles/postfix/postfix.sh b/data/Dockerfiles/postfix/postfix.sh
index 0620404d..2d3d0e64 100755
--- a/data/Dockerfiles/postfix/postfix.sh
+++ b/data/Dockerfiles/postfix/postfix.sh
@@ -39,7 +39,7 @@ query = SELECT IF(EXISTS(
           SELECT CONCAT('%u', '@', target_domain) FROM alias_domain
             WHERE alias_domain='%d'
         )
-      ) AND mailbox.tls_enforce_in = '1' AND mailbox.active = '1'
+      ) AND json_extract(`attributes`, '$.tls_enforce_in') = '1' AND mailbox.active = '1'
   ), 'reject_plaintext_session', NULL) AS 'tls_enforce_in';
 EOF
 
@@ -58,7 +58,7 @@ query = SELECT GROUP_CONCAT(transport SEPARATOR '') AS transport_maps
               WHERE alias_domain = '%d'
           )
         )
-        AND mailbox.tls_enforce_out = '1'
+        AND json_extract(`attributes`, '$.tls_enforce_out') = '1'
         AND mailbox.active = '1'
     ), 'smtp_enforced_tls:', 'smtp:') AS 'transport'
     UNION ALL
diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index c6f3cff2..89e02166 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -511,8 +511,8 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
             if (in_array($address, $gotos)) {
               continue;
             }
-            $domain       = idn_to_ascii(substr(strrchr($address, '@'), 1));
-            $local_part   = substr($address, 0, strripos($address, '@'));
+            $domain       = idn_to_ascii(substr(strstr($address, '@'), 1));
+            $local_part   = strstr($address, '@', true);
             $address      = $local_part.'@'.$domain;
             $stmt = $pdo->prepare("SELECT `address` FROM `alias`
               WHERE `address`= :address OR `address` IN (
@@ -1713,8 +1713,8 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
               $gotos = array_filter($gotos);
               $goto = implode(",", $gotos);
             }
-            $domain       = idn_to_ascii(substr(strrchr($address, '@'), 1));
-            $local_part   = substr($address, 0, strripos($address, '@'));
+            $domain = idn_to_ascii(substr(strstr($address, '@'), 1));
+            $local_part = strstr($address, '@', true);
             if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
               $_SESSION['return'] = array(
                 'type' => 'danger',
@@ -3470,7 +3470,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
             $addresses = $_data['address'];
           }
           foreach ($addresses as $address) {
-            $local_part   = substr($address, 0, strripos($address, '@'));
+            $local_part		= strstr($address, '@', true);
             $domain = mailbox('get', 'alias_details', $address)['domain'];
             try {
               $stmt = $pdo->prepare("SELECT `goto` FROM `alias` WHERE `address` = :address");