Page 11 of 105 FirstFirst ... 9101112132161 ... LastLast
Results 101 to 110 of 1048

Thread: Z-Push Zimbra Backend (Push Email, Contacts, Appointments & Tasks)

  1. #101
    jonallport's Avatar
    jonallport is offline Special Member
    Join Date
    Jul 2008
    Location
    UK
    Posts
    171
    Rep Power
    6

    Default

    Just to get back to the 'Mail for Exchange' in the from field issue...

    I've just read the release notes for ZCS 6.0.6 and apparently this is an issue that has also occured in Zimbra Mobile, but is now fixed. Is there anything in there that could be cribbed for us z-push users?

    Also, it was noted (and I have verified) that 'MfE' only appears in the 'from' for replies - I thought it had sorted itself out after updating to 1.3RC3 as I sent my usual test-mail and is came through with my correct username. Alas, back to the command prompt, I'm going to try the fix above....

    ...UPDATE...
    It works! Well done liverpoolfcfan, rep point for you methinks!
    Last edited by jonallport; 04-09-2010 at 02:27 AM. Reason: Update

  2. #102
    liverpoolfcfan's Avatar
    liverpoolfcfan is offline Outstanding Member
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    698
    Rep Power
    6

    Default

    Quote Originally Posted by jonallport View Post
    I've just read the release notes for ZCS 6.0.6 and apparently this is an issue that has also occured in Zimbra Mobile, but is now fixed. Is there anything in there that could be cribbed for us z-push users?
    Yes. I had seen that listed in the bug fixes that were to be included - but as I am on the FOSS edition, I have no access to the source code for that fix.

    Quote Originally Posted by jonallport View Post
    ...UPDATE...
    It works! Well done liverpoolfcfan, rep point for you methinks!
    Delighted it works for you.

    Can I ask your opinion on two questions I have in my mind concerning the fix?

    First, I just picked the order of the replacement fields myself

    1. zimbraPrefFromDisplay
    2. displayName
    3. cn
    4. Remove the user name part if none of the above exists (should never happen if users are set up properly)

    Do you agree with this order ?

    Second, I chose to just replace the specific text "Mail for Exchange".

    At least one user in the thread has indicated that he gets an old mailbox name on his emails instead of "Mail for Exchange" which is the default (and unchangeable) mailbox name for the Nokia application.

    UPDATE ...
    I have just discovered I can access the User-Agent string - as it is declared as a GLOBAL in index.php - so I can identify the client

    04/09/10 12:11:09 [30453] NokiaMFEFix is defined & true
    04/09/10 12:11:09 [30453] User-Agent NokiaE71/3.00(50)MailforExchange
    04/09/10 12:11:09 [30453] User-Agent contains MailforExchange

    Given that I can get all the way down to identifying a Nokia client - and thus could limit the overwrites to just Nokia phones -

    Which would be the better approach ?

    1. Only replace the specific text "Mail for Exchange" as now
    2. Always replace - which would cater for instances where other text is getting sent by the phone (as happened the user earlier in the thread)


    Thanks for your input.
    Last edited by liverpoolfcfan; 04-09-2010 at 04:01 AM. Reason: found a way to access User-Agent

  3. #103
    liverpoolfcfan's Avatar
    liverpoolfcfan is offline Outstanding Member
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    698
    Rep Power
    6

    Default

    Quote Originally Posted by liverpoolfcfan View Post
    I have fixed the "Mail for Exchange" sender name issue with this Zimbra backend.
    .....

    UPDATED: 2010-04-09 - Added User-Agent test to identify only Nokia phones
    Not sure of the best way to post updates to the script change - so I just edited the old post. http://www.zimbra.com/forums/adminis...tml#post177078

    I added a check on the User-Agent so that I only look to manipulate the email if the User-Agent contains the identifier "MailforExchange" as part of the string.

  4. #104
    liverpoolfcfan's Avatar
    liverpoolfcfan is offline Outstanding Member
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    698
    Rep Power
    6

    Default Nokia "Mail for Exchange" sender name - Enhanced Fix

    Here is an enhanced fix for the "Mail for Exchange" sender name issue with this Zimbra backend using Nokia phones.

    As before - if anyone can make the SOAP calls and/or response processing more efficient please chime in.

    The basics -
    Add new key(s) to config.php -
    Code:
    define('ZIMBRA_NOKIA_MFE_FIX',true);
    and optionally add
    define('ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE', true);
    Then add the following code to the SendMail function in zimbra.php, at the very top. So ...

    Code:
        /* Sends a message which is passed as rfc822.
         */
        function SendMail($rfc822, $forward = false, $reply = false, $parent = false) {
            debugLog('START SendMail { rfc822 = (see next line); forward = ' . $forward . '; reply = ' . $reply . '; parent = ' . $parent . ' }');
    
            $temp_file = tempnam(BASE_PATH . STATE_DIR . "/", "ZIMBRA_MSG_");
            $handle = fopen($temp_file, "w");
    becomes ...

    Code:
        /* Sends a message which is passed as rfc822.
         */
        function SendMail($rfc822, $forward = false, $reply = false, $parent = false) {
            debugLog('START SendMail { rfc822 = (see next line); forward = ' . $forward . '; reply = ' . $reply . '; parent = ' . $parent . ' }');
    
            // Nokia Mail for Exchange has a habit of sending "Mail for Exchange" instead of the sender's name
            // Searches on the internet blame this behaviour on individual phones, MFE versions, or the weather (kidding)
            // The following code block will check for the presense of a key in the config.php file - 'ZIMBRA_NOKIA_MFE_FIX'
            // If found, and set to true - the code will perform a SOAP GetInfoRequest to Zimbra 
            // The Response is searched for  
            if (defined('ZIMBRA_NOKIA_MFE_FIX')) {
              if (ZIMBRA_NOKIA_MFE_FIX == true) {
    
                debugLog( 'ZIMBRA_NOKIA_MFE_FIX is defined & TRUE' );
                $useragent =  $GLOBALS['useragent'];
                debugLog("User-Agent " . $useragent);
    
                $MFE = "MailforExchange";
                $found = stripos($useragent, $MFE);
                if ($found !== false) {
    
                  debugLog( 'User-Agent contains MailforExchange' );
    
                  $oldSender = '"Mail for Exchange" ';
                
                  // It seems some Nokia phones send garbage other than "Mail for Exchange" as the sender
                  // Enabling this second flag 'ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE' and setting it to 'true'
                  // will overwrite whatever happens to be in the sender field - good or bad.
                  if (defined('ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE')) {
                    if (ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE == true) {
                    
                      debugLog( 'ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE is defined & TRUE' );
      
                      $fromHeader = "From: ";
                      $fromPos = stripos($rfc822, "From: ");
                      $lessThan = "<";
                      $lessThanPos = stripos($rfc822, "<", $fromPos);
                      $oldSender = substr( $rfc822, ($fromPos+6), ($lessThanPos-($fromPos+6)) ); 
      
                      debugLog( 'Old sender from email [' . $oldSender . ']' );
                    
                    }
                    else {
                      debugLog( 'ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE is set to FALSE' );
                      debugLog( 'Old sender DEFAULT value [' . $oldSender . ']' );
                    }
                  }
                  else {
                    debugLog( 'ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE is NOT defined' );
                    debugLog( 'Old sender DEFAULT value [' . $oldSender . ']' );
                  }  
                  
                  $soap ='<GetInfoRequest xmlns="urn:zimbraAccount"/>';
                      
                  $response = $this->SoapRequest($soap);
    
                  $replaceWith = "DEFAULT";
    
                  if ($response) {
        
                    $array = $this->MakeXMLTree($response);
        
                    // First Choice: search prefs for 'zimbraPrefFromDisplay'
      
                    $items = $array['soap:Envelope'][0]['soap:Body'][0]['GetInfoResponse'][0]['prefs'][0]['pref_attribute_name'];
                    $total = sizeof($items);
                    
                    for ($i=0;$i<$total;$i++) {
                      if ( $items[$i] == 'zimbraPrefFromDisplay' ) {
                        $newSender = $array['soap:Envelope'][0]['soap:Body'][0]['GetInfoResponse'][0]['prefs'][0]['pref'][$i];
                        $replaceWith = 'zimbraPrefFromDisplay';
                        break;
                      }
                    }
                    
                    if ( !$newSender ) {
                      debugLog( 'pref zimbraPrefFromDisplay NOT found'  );
                      
                      // if 'zimbraPrefFromDisplay' was not found
                      // Second Choice: search attrs for 'displayName' or 'cn'
                      //$displayName = "";
                      //$cn = "";
                      
                      $items = $array['soap:Envelope'][0]['soap:Body'][0]['GetInfoResponse'][0]['attrs'][0]['attr_attribute_name'];
                      $total = sizeof($items);
                      for ($i=0;$i<$total;$i++) {
                        if ( $items[$i] == 'displayName' ) {
                          $newSender = $array['soap:Envelope'][0]['soap:Body'][0]['GetInfoResponse'][0]['attrs'][0]['attr'][$i];
                          $replaceWith = 'displayName';
                          break;
                        }
                        if ( $items[$i] == 'cn' ) {
                          $cn = $array['soap:Envelope'][0]['soap:Body'][0]['GetInfoResponse'][0]['attrs'][0]['attr'][$i];
                          $replaceWith = 'cn';
                        }
                      }
      
                      if ( !$newSender ) {
                        debugLog( 'attr displayName NOT found'  );
                        if ( !$cn ) {
                          // Third Choice: display nothing rather than "Mail for Exchange"
                          // so don't set $newSender
                          debugLog( 'attr cn NOT found'  );
                        }
                        else {
                          $newSender = $cn; 
                        }                                  
                      }
                    }
                  }
                  else {
                    debugLog( 'Got No SOAP Response' );
                  }        
    
                  // Format $newSender as ["Sender Name" ] including quotes and trailing space
                  // If not found then set to empty string to remove old sender name without replacing
                  if (!$newSender) {
                    $newSender = "";
                  }
                  else {
                    $newSender = '"' . $newSender . '" ';
                  }
    
                  debugLog( 'New sender using [' . $replaceWith .'] is [' . $newSender . ']' );
                  
                  debugLog( 'rfc822 Before: ' . $rfc822 );
      
                  $rfc822  = str_replace( $oldSender, $newSender, $rfc822 );
                  
                  debugLog( 'rfc822 After: ' . $rfc822 );
                }
                else {
                  debugLog( 'User-Agent does not contain MailforExchange - Assume non-Nokia' );
                }
      
              }
              else {
                debugLog( 'ZIMBRA_NOKIA_MFE_FIX is set to FALSE' );
              }
            }
    
    
            $temp_file = tempnam(BASE_PATH . STATE_DIR . "/", "ZIMBRA_MSG_");
            $handle = fopen($temp_file, "w");

    The code - if enabled by defining the ZIMBRA_NOKIA_MFE_FIX key and setting it to TRUE - now checks the User-Agent string for the presence of the Nokia identifier "MailforExchange" so that if an email is from an iPhone or a Windows Mobile phone, etc it will not attempt to make any changes.

    If only the ZIMBRA_NOKIA_MFE_FIX key is defined and set to TRUE, the code will replace the default sender name string "Mail for Exchange" with the contents of the first one of the following it finds

    zimbraPrefFromDisplay
    displayName
    cn

    and, if for some strange reason you have none of these set on your account it will simple remove the "Mail for Exchange" and leave the email address without a "Text" label.


    However, if the second key ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE is also defined and set to TRUE , the code will try to pick off the existing sender name from the email, and then replace it as above. This should take care of the strange behaviour described by one of the posters above where they were getting an old profile name instead of "Mail for Exchange" listed as the sender.

    Assuming it is useful to some people, please feel free to incorporate this fix into the main source

  5. #105
    barkas is offline New Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    5

    Default

    I worked a bit on the calendar side of things.

    Bugs I found:
    - a lot of error messages in the log, to the extent where it makes the app run slow and obfuscates real problems
    - no "limit" is specified in the SearchRequest, so it only pulls 30 calendar items at most (max limit is 1000, which i specified as dirty hack, the real solution would be to do limit 50 and offsets, but I don't know how to check how many appointments there are)
    - calendar items without attached text are eaten, because MakeXMLTree can't cope with "complete" nodes without value

    With the fixes I did I was able to do a complete resync from zimbra to my phone with MfE. Contacts work well also.
    I'm not sure what will happen if I edit some appointment on the phone and try to get it into zimbra.
    EDIT: just checked, works nicely.

    So please accept this patch, which fixes all of that (the first one only mostly).
    Code:
    --- C:/Users/mpeter/AppData/Local/Temp/zimbra.ph-revBASE.svn001.tmp.php	Sat Apr 10 00:37:24 2010
    +++ Z:/tmp/zimbrabackend/zimbra.php	Sat Apr 10 00:36:36 2010
    @@ -200,6 +200,7 @@
                 $folders = array(); $j = 0;
                 for ($i=0;$i<$total;$i++) {
                     if ($array[$i]['tag'] == 'folder') {
    +					$this->_folders[$j]=new stdClass();
     					$this->_folders[$j]->id = $array[$i]['id'];
     					$this->_folders[$j]->devid = $array[$i]['id'];
                         $this->_folders[$j]->name = $array[$i]['name'];
    @@ -347,7 +348,7 @@
             $folder->serverid = $devid;
     
             $index = $this->GetFolderIndex($devid);
    -		$devid = $this->_folders[$i]->devid;
    +		$devid = $this->_folders[$index]->devid;
             $folder->displayname = $this->_folders[$index]->name;
     		$folder->parentid = $this->_folders[$index]->parentid;
             
    @@ -554,7 +555,7 @@
                     // DEPRECATED $soap ='<GetApptSummariesRequest s="'.$cutoffdate.'000" e="'.$next100days.'000" l="'.$folderid.'" xmlns="urn:zimbraMail" />';
                     // calExpandInstStar="'.$cutoffdate.'000" calExpandInstEnd="'.$next100days.'000"
                     // <query>inid:'.$folderid.' AND appt-start:&gt;='.$cutoffdate.'000 AND appt-end:&lt;='.$next100days.'000</query>
    -                $soap ='<SearchRequest types="appointment" more="1" xmlns="urn:zimbraMail">
    +                $soap ='<SearchRequest types="appointment" more="1" limit="1000" xmlns="urn:zimbraMail">
                                 <query>inid:'.$id.' AND appt-start:&gt;='.$cutoffdate.'000</query>
                             </SearchRequest>';
                     break;
    @@ -638,7 +639,7 @@
                         break;
     
                     case 'appointment':
    -                    //debugLog(print_r($array,true));
    +                    debugLog(print_r($array,true));
                         $items = $array['soap:Envelope'][0]['soap:Body'][0]['SearchResponse'][0]['appt'];
                         $total = count($items);
     
    @@ -2201,7 +2202,13 @@
     
                         case 'complete':
                             array_push($hash_stack, $val['tag']);
    -                        $ret = $this->ComposeArray($ret, $hash_stack, $val['value']);
    +                        if (isset($val['value'])){
    +							$ret = $this->ComposeArray($ret, $hash_stack, $val['value']);
    +						}else if (isset($val['attributes'])){
    +                            $ret = $this->ComposeArray($ret, $hash_stack, $val['attributes']);
    +                        }else{
    +							$ret = $this->ComposeArray($ret, $hash_stack, '');
    +						}
                             array_pop($hash_stack);
     
                             // handle attributes
    @@ -2247,6 +2254,9 @@
     
             // get current element
             $element = array_shift($elements);
    +		if (!array_key_exists($element, $array)){
    +			$array[$element]=array();
    +		}
     
             // does the current element refer to a list
             if(sizeof($elements) > 0) {
    Last edited by barkas; 04-09-2010 at 03:51 PM.

  6. #106
    gnosbush is offline Active Member
    Join Date
    Jun 2009
    Posts
    38
    Rep Power
    5

    Default

    So please accept this patch, which fixes all of that (the first one only mostly).
    Thanks for the work on the script. I have been working on changes to revision 28 for some time and had aready come up with your first two but the others look great and I have incorporated them. I apperciate you taking the time and helping with this project.

    Revision 28 also contains some other changes that should help reduce other annoying errors and a few other bug fixes.

    Let me know how things work with the latest revision.

  7. #107
    andywhy's Avatar
    andywhy is offline Intermediate Member
    Join Date
    Mar 2010
    Location
    /Earth/Europe/Germany/Lower\ Saxony/Hannover
    Posts
    22
    Rep Power
    5

    Default

    Revision 28 works quite good...

    Push functionality is working fine, but debug.txt is flooded realy fast about 100MB per 10 min, so i set debug.txt as link to /dev/null ;-) not the fine art but working. Recurring appointments, created in zimbra are synced to cellphone without the recurring as single appointment. When they are created on cellphone everything is fine and they are also shown as recurring appointments in zimbra.

    Thanks for your work,
    Andreas

  8. #108
    liverpoolfcfan's Avatar
    liverpoolfcfan is offline Outstanding Member
    Join Date
    Oct 2009
    Location
    Dublin, IRELAND
    Posts
    698
    Rep Power
    6

    Default

    You can disable debugging to stop debug.txt growth.

    I am not near my server right now, but I believe the filename is wbxml.php in the z-push root folder. The first setting in there is for debug - true or false. Set this to false, then delete debug.txt and restart your web server. No more debug.txt

    To re-enable just recreate debug.txt and set it's permissions to allow writes, then edit the wbxml.php to set the debug value back to true, and restart the web server.

    Hope this helps.

  9. #109
    andywhy's Avatar
    andywhy is offline Intermediate Member
    Join Date
    Mar 2010
    Location
    /Earth/Europe/Germany/Lower\ Saxony/Hannover
    Posts
    22
    Rep Power
    5

    Default

    Tried it, but WBXML_DEBUG was set to false, and debug.txt still growth. I will search the switch when i have some time.

    Greetings,
    Andreas

  10. #110
    barkas is offline New Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    5

    Default

    I had to roll back to 27, 28 breaks somewhere with MfE and I don't know where and how - debug.txt remains empty of errors and the phone says "System Error".

Page 11 of 105 FirstFirst ... 9101112132161 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. fatal: parameter "smtpd_recipient_restrictions"
    By Robin in forum Administrators
    Replies: 8
    Last Post: 12-22-2010, 05:48 AM
  2. Replies: 12
    Last Post: 02-25-2008, 07:28 PM
  3. /tmp filling
    By Nutz in forum Administrators
    Replies: 8
    Last Post: 02-22-2008, 02:00 AM
  4. Replies: 22
    Last Post: 12-02-2007, 05:05 PM
  5. zmtlsctl give LDAP error
    By sourcehound in forum Administrators
    Replies: 5
    Last Post: 03-11-2007, 03:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •