#014242: Cannot append email through IMAP

Description:

Hi,

I use the Mail-classes of ezComponent 2008.1 to retrieve mail from an IMAP-server. I then want to create an archive folder and store the mail in that folder. For the latter I use the function 'append' of the class 'ezcMailImapTransport'. This works fine.

The above doesn't work properly when I use version 2008.2. The append-function throws an exception:

An error occured while sending or receiving mail. The IMAP server could not append message to mailbox 'INBOX/archive': FLAGS (\Seen)).

I found out the problem lies in the function 'getNextLine' of class 'ezcMailImapSet', which is found in 'imap_set.php' of version 2008.2. If I overwrite this with version 2008.1, the append-function works as expected! It looks like issue #13878 (Endless loop in ezcMailParser) introduced this problem!


Environment:

Operating System: Debian GNU/Linux 4.0
PHP Version: PHP 5.2.0-8+etch10 (cli) (built: Jan 18 2008 18:52:58)
Database and version: MySQL 5.0.51
Browser (and version): FireFox 3.0.5


Steps to Reproduce:

Use IMAP-connection and create an archive-mailfolder. Read a mail and try to append this in the archive-mailfolder.


- Attachments
mailProcessor.class.php (2.9 kb)
[Download] [Permanent Link]
Code using the append function

- Comments

In the uploaded file 'mailProcessor.class.php', change MAIL_FOLDER_ARCHIVE to 'archive'. This named constant is defined elsewhere in my code (not provided).

Also comment-out the following line, since the method is not provided (and that is not the issue here)

ezcMailCharsetConverter::setConvertMethod(array('MailAccountsController', '__convertToUTF8Iconv')); // override ezc own function of convertToUTF8Iconv()

#259700 by Enforcer x on January 7th, 2009 [Permanent Link]

Hello,

we've looked at this issue, and tried to reproduce it. Unfortunately, we can't and it works all fine here. We might be expecting that your IMAP server returns something that is unexpected for us. It would greatly help us if you could provide us with a network trace with a tool like Wireshark. Debian has a package for it which you can install with "apt-get install wireshark". It's not too hard to use, and I'm confident that you will manage :-) You can just save the network dump that shows the connection to the SMTP server and attach it to this issue.

regards,
Derick

#259718 by Derick Rethans on January 9th, 2009 [Permanent Link]

Okay, I will look into Wireshark. Maybe it does help that the IMAP server is actually Microsoft Exchange. I'm not sure which version, I have to look into that (not managed by me)

#259727 by Enforcer x on January 9th, 2009 [Permanent Link]

Here's the Wireshark output:

"901", "5.426006", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * OK Microsoft Exchange Server 2007 IMAP4 service ready"
"903", "5.426109", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0001 LOGIN testaccount@domain.nl xxx"
"904", "5.438117", "217.115.197.41", "217.115.192.102", "IMAP", "Response: A0001 OK LOGIN completed."
"905", "5.438666", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0002 LIST "" """
"906", "5.440667", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * LIST (\Noselect \HasChildren) "/" """
"907", "5.441119", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0003 LIST "" "*""
"908", "5.445452", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * LIST (\HasNoChildren) "/" Calendar"
"909", "5.452520", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0004 SELECT "INBOX""
"910", "5.460726", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * 2 EXISTS"
"911", "5.461677", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0005 SEARCH UNDELETED"
"912", "5.464770", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * SEARCH 1 2"
"913", "5.465129", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0006 FETCH 1,2 RFC822.SIZE"
"914", "5.466818", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * 1 FETCH (RFC822.SIZE 4342)"
"916", "5.506810", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * 2 FETCH (RFC822.SIZE 5170916)"
"918", "5.507716", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0007 SEARCH UNDELETED"
"919", "5.510711", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * SEARCH 1 2"
"920", "5.511670", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0008 FETCH 1,2 RFC822.SIZE"
"921", "5.513354", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * 1 FETCH (RFC822.SIZE 4342)"
"923", "5.550746", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * 2 FETCH (RFC822.SIZE 5170916)"
"925", "5.553821", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0001 FETCH 1 RFC822"
"926", "5.561028", "217.115.197.41", "217.115.192.102", "IMAP", "Response: * 1 FETCH (RFC822 {4996}"
"927", "5.561170", "217.115.197.41", "217.115.192.102", "IMAP", "Response: Received: from relay.n01.nxs.nl (217.115.192.39) by"
"929", "5.561220", "217.115.197.41", "217.115.192.102", "IMAP", "Response: 15:28 +0100"
"930", "5.561227", "217.115.197.41", "217.115.192.102", "IMAP", "Response: .22; 'global_tokens.fs:distance:11':"
"932", "5.561985", "217.115.197.41", "217.115.192.102", "IMAP", "Response: ME-Version: 1.0"
"934", "5.603981", "217.115.197.41", "217.115.192.102", "IMAP", "Response: A0001 OK FETCH completed."
"940", "6.030607", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0009 APPEND INBOX/archive/2009/01 (\SEEN) {5206}"
"941", "6.032387", "217.115.197.41", "217.115.192.102", "IMAP", "Response: + Ready for additional command text."
"973", "6.120513", "217.115.192.102", "217.115.197.41", "IMAP", "Request: A0010 LOGOUT"

This produces the exception:

An error occured while sending or receiving mail. The IMAP server could not append message to mailbox 'INBOX/archive/2009/01': FLAGS (\Seen)).

#259757 by Enforcer x on January 12th, 2009 [Permanent Link]

Could you perhaps add the raw binary dump (so not the CVS export) as attachment to this issue? I am afraid that things are not as clear as they should be now.

#259764 by Derick Rethans on January 12th, 2009 [Permanent Link]

Did you try using the ezcMailImapTransport->copyMessages() function? A direct copy is much better than parsing a mail, regenerating the mail then appending the mail. Not to mention that the mail source will be different than the original after calling generate().

#259758 by Alexandru Stanoi on January 12th, 2009 [Permanent Link]

Ah, didn't know about the ezcMailImapTransport->copyMessages() function. Will try now!

#259759 by Enforcer x on January 12th, 2009 [Permanent Link]

The ezcMailImapTransport->copyMessages() function works fine with the laters ezComponents! No exceptions are thrown! Nice to see there was such a function. I was actually looking for a move-function, but this will do (also lot faster!). Thanks!

Still, the append issue is not solved... any suggestions?

#259761 by Enforcer x on January 12th, 2009 [Permanent Link]

We will try to fix the append() problem. It could be a Microsoft Exchange issue.

#259762 by Alexandru Stanoi on January 12th, 2009 [Permanent Link]

Okay, thanks. If you need any input, please let me know (I'll save the append-code for reproduction).

#259763 by Enforcer x on January 12th, 2009 [Permanent Link]

Hi Derick Rethans,

Yes, I could send the RAW output, but preferrably by personal emailaddress. Is that possible?

#259765 by Enforcer x on January 12th, 2009 [Permanent Link]

Sure, just dr _at_ ez _dot_ no

#259782 by Derick Rethans on January 13th, 2009 [Permanent Link]

Okay, the RAW file hase been sent! (how can I add comment right under your comment with an ident??)

#259783 by Enforcer x on January 13th, 2009 [Permanent Link]

This issue seems to be about the FETCH command and not about the APPEND command. Microsoft Exchange returns the line ' FETCH (\Seen))' after the FETCH response, when it should instead return this before the FETCH response. Normally a line ')' should be returned after the FETCH response.

I added a test for it based on the wireshark output received. The fix should come in a few days.

#259980 by Alexandru Stanoi on January 27th, 2009 [Permanent Link]

Nice to read that you found the cause of this error! Looking forward to a fix.

#259981 by Enforcer x on January 27th, 2009 [Permanent Link]

Fixed in SVN rev. 9795. It will be available in Mail 1.6.1 (part of eZ Components 2008.2.1).

#260065 by Alexandru Stanoi on February 4th, 2009 [Permanent Link]

- History
Properties
Type Bug
Priority Medium
Component Components » Mail
Affects 1.6 - Mail 1.6
Fix Versions 2008.2.1 - eZ components 2008.2.1
2009.1alpha1 - eZ components 2009.1alpha1
Reporter Enforcer x
Responsible Alexandru Stanoi
Status 0 Closed
Resolution Fixed
Created January 7th, 2009
Updated February 5th, 2009
Resolved February 4th, 2009
 
Navigation [Permanent Link]
Previous Issue
Back to Issues List
Next Issue: #015537
  Graph shows to small and truncated rotated axis labels