pilerimport does not work with zarafa IMAP Server

Issue #107 resolved
Former user created an issue

Import with pilerimport fails for me when using the import facility to import from an IMAP Server, in my case zarafa (http://www.zarafa.com/). It does work if i test it with my cyrus server though.

i am using piler-0.1.23 on Centos 6.4, 64bit

I am not good in understanding complex C-Code, therefore i was not able to find the reason for the failing import, but from what i understand the buf Variable does not contain what "tag" and "tagok" are looking for, it is always lagging one response behind:

sh-4.1$ pilerimport -i $host -u username -p 'password'
processing folder: Public folders... error: * 0 EXISTS
* 0 RECENT
processing folder: INBOX... error: * FLAGS (\Seen \Draft \Deleted \Flagged \Answered $Forwarded)
* OK [PERMANENTFLAGS (\Seen \Draft \Deleted \Flagged \Answered $Forwarded)] Permanent flags
* OK [UIDNEXT 1] Predicted next UID
* OK [UIDVALIDITY 5] UIDVALIDITY value
processing folder: Outbox... error: A4 OK [READ-WRITE] SELECT completed
processing folder: Deleted Items... error: * 1 EXISTS
* 0 RECENT
processing folder: Sent Items... error: * FLAGS (\Seen \Draft \Deleted \Flagged \Answered $Forwarded)
* OK [PERMANENTFLAGS (\Seen \Draft \Deleted \Flagged \Answered $Forwarded)] Permanent flags
* OK [UIDNEXT 1637417] Predicted next UID
* OK [UNSEEN 1] First unseen message
* OK [UIDVALIDITY 3688533] UIDVALIDITY value
processing folder: Drafts... error: A5 OK [READ-WRITE] SELECT completed
processing folder: Junk E-mail... error: * 0 EXISTS
* 0 RECENT

For each folder it is reporting errors. now what i did is, that i entered 3 debugging lines into imap.c, line 86:

   n = recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl);

   printf("debug tag: %s\n", tag);
   printf("debug tagok: %s\n", tagok);
   printf("debug folder: %s\n", folder);

   if(!strstr(buf, tagok)){

from what i understand your code checks, that the contents of tagok is contained in buf, but in my case this is the debugging information:

processing folder: Public folders... error 1: * 0 EXISTS
* 0 RECENT

debug tag: A4
debug tagok: A4 OK
debug folder: Public folders

So we are trying to find "A4 OK" in buf, but buf has "0 EXISTS * 0 RECENT"

So are packets coming in in some wrong order? The logfile of zarafa-gateway.log also shows:

Tue Jul 23 15:58:52 2013: [26889] Starting worker process for IMAP request
Tue Jul 23 15:58:53 2013: [30580] IMAP Login from $host for user $user
**Tue Jul 23 15:59:05 2013: [30587] Failed to read line: Broken pipe**
Tue Jul 23 15:59:05 2013: [30587] Client $pilerhost thread exiting
Tue Jul 23 15:59:57 2013: [26889] Starting worker process for IMAP request
Tue Jul 23 15:59:58 2013: [30619] Disconnecting client.

Could it be that pilerimap does not read until the end of the tcp stream? this is what zarafa-gateways show in detail, so it seems to be replying properly:

Tue Jul 23 14:30:20 2013: [23399] Starting worker process for IMAP request
Tue Jul 23 14:30:20 2013: [26682] > * OK [CAPABILITY IMAP4rev1 LITERAL+ STARTTLS AUTH=PLAIN] Zarafa IMAP gateway ready
Tue Jul 23 14:30:20 2013: [26682] < A1 CAPABILITY
Tue Jul 23 14:30:20 2013: [26682] > * CAPABILITY IMAP4rev1 LITERAL+ STARTTLS AUTH=PLAIN CHILDREN XAOL-OPTION NAMESPACE QUOTA IDLE
Tue Jul 23 14:30:20 2013: [26682] > A1 OK CAPABILITY Completed
Tue Jul 23 14:30:20 2013: [26682] < A2 LOGIN user "password"
Tue Jul 23 14:30:21 2013: [26682] IMAP Login from host for user user
Tue Jul 23 14:30:21 2013: [26682] > A2 OK [CAPABILITY IMAP4rev1 LITERAL+ CHILDREN XAOL-OPTION NAMESPACE QUOTA IDLE] LOGIN completed
Tue Jul 23 14:30:21 2013: [26682] < A3 LIST "" "*"
Tue Jul 23 14:30:21 2013: [26682] > * LIST (\HasChildren) "/" "Public folders"
Tue Jul 23 14:30:21 2013: [26682] > * LIST (\HasNoChildren) "/" "INBOX"
Tue Jul 23 14:30:21 2013: [26682] > * LIST (\HasNoChildren) "/" "Outbox"
Tue Jul 23 14:30:21 2013: [26682] > * LIST (\HasNoChildren) "/" "Deleted Items"
Tue Jul 23 14:30:21 2013: [26682] > * LIST (\HasNoChildren) "/" "Sent Items"
Tue Jul 23 14:30:21 2013: [26682] > * LIST (\HasNoChildren) "/" "Drafts"
Tue Jul 23 14:30:21 2013: [26682] > * LIST (\HasNoChildren) "/" "Junk E-mail"
Tue Jul 23 14:30:21 2013: [26682] > A3 OK LIST completed
Tue Jul 23 14:30:21 2013: [26682] < A4 SELECT "Public folders"
Tue Jul 23 14:30:22 2013: [26682] > * 0 EXISTS
Tue Jul 23 14:30:22 2013: [26682] > * 0 RECENT
Tue Jul 23 14:30:22 2013: [26682] > * FLAGS (\Seen \Draft \Deleted \Flagged \Answered $Forwarded)
Tue Jul 23 14:30:22 2013: [26682] > * OK [PERMANENTFLAGS (\Seen \Draft \Deleted \Flagged \Answered $Forwarded)] Permanent flags
Tue Jul 23 14:30:22 2013: [26682] > * OK [UIDNEXT 1] Predicted next UID
Tue Jul 23 14:30:22 2013: [26682] > * OK [UIDVALIDITY 5] UIDVALIDITY value
Tue Jul 23 14:30:22 2013: [26682] > A4 OK [READ-WRITE] SELECT completed
Tue Jul 23 14:30:22 2013: [26682] < A5 SELECT "INBOX"
Tue Jul 23 14:30:22 2013: [26682] > * 1 EXISTS
Tue Jul 23 14:30:22 2013: [26682] > * 0 RECENT
Tue Jul 23 14:30:22 2013: [26682] > * FLAGS (\Seen \Draft \Deleted \Flagged \Answered $Forwarded)
Tue Jul 23 14:30:22 2013: [26682] > * OK [PERMANENTFLAGS (\Seen \Draft \Deleted \Flagged \Answered $Forwarded)] Permanent flags
Tue Jul 23 14:30:22 2013: [26682] > * OK [UIDNEXT 1637417] Predicted next UID
Tue Jul 23 14:30:22 2013: [26682] > * OK [UNSEEN 1] First unseen message
Tue Jul 23 14:30:22 2013: [26682] > * OK [UIDVALIDITY 3688533] UIDVALIDITY value
Tue Jul 23 14:30:22 2013: [26682] > A5 OK [READ-WRITE] SELECT completed

i also tried it with a different zarafa server on a different network segment but the results are the same. i have no ideas anymore.

any help is appreciated. thank you j

Comments (17)

  1. Janos SUTO repo owner

    Perhaps zarafa has some imap options the import utility doesn't like. Is it possible to create a test account, a few folders, and put some emails, (even spam is ok for test purposes), then I would test it. If it's inconvenient then I'll setup zarafa for myself, but it takes time, and the test account method is faster.

  2. James

    hi jsuto, thank you for your response. OK i will then create a virtual machine with the same zarafa versions i am using in two locations (they differ slightly, but both are not the absolutely newest version). i will need a day or so until manage set it up and will then contact you.

  3. James

    Hello jsuto, thank you for your quick response on this and the quick fix. i can confirm that i was now able to import a complete mailbox of one of our users from zarafa successfully and will continue to do some further tests and will inform if i encounter anything.

    many thanks.

  4. James

    Hello jsuto, i have now imported another mailbox and there i encounter the problem that it seems to hang or somehow at least stop at a certain point.

    after waiting about 15 hours in this state i stopped the importjob and ran it again, but it hangs again at the same point. i then also told it to skip that folder but again it stops.

    It stopped after a certain Folder which only has 1 message and it also successfully read that message. i ran it again and it noticed that it is duplicate but it won't continue:

    processing folder: $FOLDERNAME4... found 1 messages
    processing: $FOLDERNAME4-1.txt
    duplicate: $FOLDERNAME4-1.txt (id: 4000000051f69bc0101ebb5c00063fec9225)
    

    at this stage is stays forever.

    ran it again and told it to skip that folder:

    processing folder: $FOLDERNAME1... found 1 messages
    processing: $FOLDERNAME1-1.txt
    duplicate: $FOLDERNAME1.txt (id: 4000000051f7727b084ec32c00911f86a70d)
    
    processing folder: $FOLDERNAME2... found 0 messages
    processing folder: $FOLDERNAME3... found 1 messages
    processing: $FOLDERNAME3-1.txt
    duplicate: $FOLDERNAME3-1.txt (id: 4000000051f7727b1325f46400c64a3cf7b9)
    
    SKIPPING FOLDER: $FOLDERNAME4
    

    again it stays like this forever and does not continue. Meanwhile i see in top that "pilerimport" is doing something, but i have no clue what it does. it consumes 99.5% CPU

      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     4248 piler     20   0  228m 3632 2208 R 99.5  0.5  14:19.86 pilerimport
    

    how can i help you debug what it is doing or where it is stuck or what it is waiting for?

    thanks

  5. Janos SUTO repo owner

    It's possible that either the imap routine has some more problem or the piler parser. To determine which one please check the last file pilerimport downloaded. It can be $FOLDERNAME4-1.txt (or -2.txt).

    Please view the file whether it's a complete email, has its header and proper end. If so, then try to import it: pilerimport -e < $FOLDERNAME4-1.txt

    If it's processed properly then it's an imap error otherwise a parser error.

  6. James

    Hello jsuto. Problem still persists but I did not manage to continue testing it the last days. i hope to be able to test on the weekend. thanks for standing by.

  7. James

    i still have not found the time to import all the orphaned (when staff leaves the company) mailboxes from my users yet, had stopped the archiving job after the errors had happened. i will be getting more storage for backup purposes in the next weeks and will surely test it with zarafa again and let you know. sorry for letting you wait so long

  8. Janos SUTO repo owner

    No problem. However be sure to check out the latest master branch, since the imap stuff has improved since the last time you were here.

  9. James

    Hello Jsuto, sorry for taking so long to reply to you but we now managed to make final tests on your fix and were able to successfully import mailboxes from zarafa-imap. We imported multiple mailboxes in the meantime and all went fine.

    (Our current Zarafa Server Version is 7.1.11)

    so thank you for fixing it and if you ever need access to zarafa test systems, do contact me.

  10. Log in to comment