This will add the default domain again if the email address does not contain
[squirrelmail.git] / class / mime / Rfc822Header.class.php
index 0b35277aab2d6bfb3f4349623eb69e088a759817..ca5ade5e8b6d8859cd7c1fd9f15061ed8e8435b2 100644 (file)
@@ -293,13 +293,13 @@ class Rfc822Header {
                 // check the next token in case comments appear in the middle of email addresses
                 $prevToken = end($aTokens);
                 if (!in_array($prevToken,$aSpecials,true)) {
-                    if (isset($address{$i+1}) && !in_array($address{$i+1},$aSpecials,true)) {
+                    if ($i+1<strlen($address) && !in_array($address{$i+1},$aSpecials,true)) {
                         $iEnd = strpos($address,' ',$i+1);
                         if ($iEnd) {
                             $sNextToken = trim(substr($address,$i+1,$iEnd - $i -1));
                             $i = $iEnd-1;
                         } else {
-                            $sToken = trim(substr($address,$i+1));
+                            $sNextToken = trim(substr($address,$i+1));
                             $i = $iCnt;
                         }
                         // remove the token
@@ -469,7 +469,11 @@ class Rfc822Header {
                 if ($sHost && $oAddr->mailbox) {
                     $oAddr->host = $sHost;
                 }
-            }
+            } else if (!$grouplookup && !$oAddr->host) {
+                if ($sHost && $oAddr->mailbox) {
+                    $oAddr->host = $sHost;
+                }
+           }
           }
           if (!$aAddrBookAddress && $oAddr->mailbox) {
               $aProcessedAddress[] = $oAddr;