Issue with Optimize IMAP feature

I have a server where IMAP is overwhelmingly used for mailboxes so am looking to use the optimize-imap.py script provided by Kopano.

I ran this script on 3 users on the server without error, but for some reason it throws up an error when I try to run the script now.

Running:

python /usr/share/doc/kopano-gateway/optimize-imap.py username

Returns the following error:

[error  ] VMIME exception: No recipient specified.
Traceback (most recent call last):
  File "/usr/share/doc/kopano-gateway/optimize-imap.py", line 55, in <module>
    main()
  File "/usr/share/doc/kopano-gateway/optimize-imap.py", line 51, in main
    generate_imap_message(item)
  File "/usr/share/doc/kopano-gateway/optimize-imap.py", line 19, in generate_imap_message
    eml = item.eml(received_date=True)
  File "/usr/lib/python2.7/site-packages/kopano/item.py", line 525, in eml
    self.emlfile = inetmapi.IMToINet(self.store.server.mapisession, None, self.mapiobj, sopt)
MAPI.Struct.MAPIErrorCallFailed: MAPI error 80004005 (MAPI_E_CALL_FAILED)

This error occurs running the script for any user. The username specified is correct and appears when running:

kopano-admin -l

Can anyone offer any advice on how to diagnose this?

Many thanks in advance.

Hi markct,

maybe you should run the script on this user with -l DEBUG parameter to get more information on where the script actually breaks.

My guess from the script is that it may be related to a broken item or some issue with chars within the message.

Andreas

Many thanks for this Andreas.

It looks like you’re right in that I can see it’s getting stuck processing individual items. However there’s some other weird behaviour.

I ran:

python /usr/share/doc/kopano-gateway/optimize-imap.py username -l DEBUG

But the script then immediately began processing completely different mailboxes:

DEBUG:optimize-imap:Processing user username2
INFO:optimize-imap:Processing folder Deleted Items
INFO:optimize-imap:Processing folder Drafts
INFO:optimize-imap:Processing folder Inbox
DEBUG:optimize-imap:Processing user username3
INFO:optimize-imap:Processing folder Deleted Items
INFO:optimize-imap:Processing folder Drafts
INFO:optimize-imap:Processing folder Inbox

Whilst processing username3 the script returned the original error.

My guess is that the script is trying to optimise all mailboxes, and not just the one I specified.

For my purposes it’s okay for the script to process all mailboxes. It would be good to do 1 mailbox at a time but it’s not the end of the world. However, is there a way to get the script to skip items it has trouble with and continue processing?

Hi Markct,

it seems to me that you’re calling the script wrong way since you’re missing -u in front of the username… This will actually not limiting the processing to a single user.

The script is just needed for OLD (pre Zarafa 7.1 if I’m not completely wrong) installations where additional properties that are needed for speeding up the gateway not being set… So it makes only sense for those that have an old database even with older items that need just being reprocessed once for speed up the gateway.

Andreas

That was silly of me. Many thanks, got it working on all mailboxes now!