<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>278082</bug_id>
          
          <creation_ts>2011-07-19 12:39:57 +0000</creation_ts>
          <short_desc>KMail2 can not synchro message&apos;s flags with IMAP on MSExchange server 2003</short_desc>
          <delta_ts>2014-05-03 03:47:41 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>kmail2</product>
          <component>general</component>
          <version>4.7</version>
          <rep_platform>Arch Linux</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Andrew Kovalev">sailor-02</reporter>
          <assigned_to name="Kevin Ottens">ervin</assigned_to>
          <cc>abone27</cc>
    
    <cc>alex</cc>
    
    <cc>dns_hmpf</cc>
    
    <cc>gapon007</cc>
    
    <cc>gspr</cc>
    
    <cc>notz76</cc>
    
    <cc>paul_crook</cc>
    
    <cc>pim-bugs-null</cc>
    
    <cc>rauchweihe</cc>
    
    <cc>tmp_prince-promo</cc>
    
    <cc>vkrause</cc>
    
    <cc>woebbeking</cc>
    
    <cc>wolf.behrenhoff</cc>
    
    <cc>wstephenson</cc>
          
          <cf_commitlink>http://commits.kde.org/kdepim-runtime/c561149538336804f212f5a12ea6cf3d1a3a19f5</cf_commitlink>
          <cf_versionfixedin>4.11.3</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>60</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1143509</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew Kovalev">sailor-02</who>
    <bug_when>2011-07-19 12:39:57 +0000</bug_when>
    <thetext>Version:           2.1.1 (using Devel) 
OS:                Linux

MSExchange 2003 account on the server is connected via IMAP, the Sent Items folder designated folder on the server.
when sending emails - jumping bug:
&quot;Append failed, server replied: A000182 BAD Protocol Error: Specified set of flags is not valid&quot;
Letters to the server are not synchronized and evaporates completely.

Reproducible: Always

Steps to Reproduce:
connect to IMAP account on MSExchange server 2003

Actual Results:  
every time sending a letter the bug appears

Expected Results:  
Expected that sent letter will be moved to Sent box on server</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1167917</commentid>
    <comment_count>1</comment_count>
    <who name="">notz76</who>
    <bug_when>2011-09-28 16:20:10 +0000</bug_when>
    <thetext>Have exact the same problem. Also with ms exchange 2003. Makes kmail unuseable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1189498</commentid>
    <comment_count>2</comment_count>
    <who name="gapon">gapon007</who>
    <bug_when>2011-11-23 14:32:55 +0000</bug_when>
    <thetext>Not sure whether it is the same or not; cannot store any sent emails on my server (using IMAP), the error is:

Append failed A004632 BAD Invalid flag specified

So, right now, ALL THE SENT EMAILS ARE STORED ONLY LOCALLY (!).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1203657</commentid>
    <comment_count>3</comment_count>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2011-12-22 14:39:58 +0000</bug_when>
    <thetext>Any progress on this?

Same error message &quot;Append failed, server replied:&quot; &quot;BAD Protocol Error: Specified set of flags is not valid&quot; with KMail Version 4.7.3, Using KDE Development Platform 4.7.3 (4.7.3), on Kubuntu 11.10. Connecting to a Microsoft Exchange 2003 server.

Appears to be more annoying than fatal as the messages are being appended to the folder on the server. Googling of &quot;Specified set of flags is not valid&quot; looks like other mail clients have hit this issue and the simplest explanation is Kmail is possibly not checking what flags that Exchange 2003 supports?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1203705</commentid>
    <comment_count>4</comment_count>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2011-12-22 15:53:49 +0000</bug_when>
    <thetext>The following blog entry (see below) may be relevant though unfortunately the link to imap2exchange which is supposed to explain what flags Exchange doesn&apos;t support is broken (okay found a working link - see below). To summaries it looks like the main thing that Exchange doesn&apos;t support is user-defined flags. Is Kmail try to generate user defined flags???

Anyone know how to get logs out of Kmail/Akonadi IMAP server?

http://geek.co.il/wp/2008/06/03/copying-mail-to-ms-exchange-server-using-imap

okay link to imap2exchange is http://code.google.com/p/imap2exchange/wiki/Background

and also of relevance
http://serverfault.com/questions/115769/which-imap-flags-are-reliably-supported-across-most-mail-servers</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1213021</commentid>
    <comment_count>5</comment_count>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2012-01-11 12:30:10 +0000</bug_when>
    <thetext>With reference my comment #3. I was being fooled by the Kmail interface that mail was still being appended to the server. It is not. I now concur completely with comment #2.

In fact the situation is worse. The mails look like they&apos;ve been append but its just a local cached copy. Accessing the server from another client shows the emails are not on the server. In Kmail, once the cached copy falls away, I get &quot;Remote id is empty or invalid&quot; when trying to open mails that are listed in the &quot;Sent&quot; folder.

I&apos;m getting this problem with Exchange but also with another mail server that I can&apos;t identify. The only details I have on its identity is that when you connect it says:
* OK IMAP4 server ready

and its capability statement reads:

CAPABILITY IMAP4rev1 UIDPLUS NAMESPACE QUOTA CHILDREN AUTH=CRAM-MD5 AUTH=DIGEST-MD5 AUTH=PLAIN</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1213029</commentid>
    <comment_count>6</comment_count>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2012-01-11 12:55:35 +0000</bug_when>
    <thetext>flagging information on the mystery server:
FLAGS (\Answered \Flagged \Deleted \Seen \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $MDNSent)] flags can be changed</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1213042</commentid>
    <comment_count>7</comment_count>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2012-01-11 13:27:34 +0000</bug_when>
    <thetext>How to get Akonadi IMAP debug logs:
http://techbase.kde.org/Projects/PIM/Akonadi/Debug_IMAP

In summary, from a console do:

&gt; export KIMAP_LOGFILE=/tmp/imap.log
&gt; akonadictl restart

then look through the list of /tmp/imap.log.PID files to find the error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1213092</commentid>
    <comment_count>8</comment_count>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2012-01-11 15:12:29 +0000</bug_when>
    <thetext>Okay got some logging information from Akondi. Looks like its sending the flag $SENT when it clearly should be using the flag $MDNSent.


Akondi IMAP logs for the MS Exchange 2003 server:

C: A000035 SELECT &quot;Sent Items&quot;
S: * 190 EXISTS
S: * 0 RECENT
S: * FLAGS ( \Seen \Answered \Flagged \Deleted \Draft $MDNSent )
S: * OK Permanent flags [ PERMANENTFLAGS ( \Seen \Answered \Flagged \Deleted \Draft $MDNSent )  ]
.
.
C: A000074 APPEND &quot;Sent Items&quot; (\Seen $SENT) {645}
S: A000074 BAD Protocol Error: Specified set of flags is not valid .
C: A000075 LOGOUT
S: * BYE Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 signing off.
S: A000075 OK LOGOUT completed.


For my mystery server:

C: A000020 SELECT &quot;Sent&quot;
S: * 101 EXISTS
S: * 0 RECENT
S: * FLAGS ( \Answered \Flagged \Deleted \Seen \Draft $MDNSent )
S: * OK flags can be changed [ PERMANENTFLAGS ( \Answered \Flagged \Deleted \Seen \Draft $MDNSent )  ]
.
.
C: A000074 APPEND &quot;Sent&quot; (\Seen $SENT) {522}
S: A000074 BAD invalid APPEND command syntax, invalid message flags list syntax
C: A000075 UID STORE 4078 FLAGS (\Seen)
S: A000075 OK STORE complete
C: A000076 LOGOUT
S: * BYE disconnecting
S: A000076 OK LOGOUT complete</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1213709</commentid>
    <comment_count>9</comment_count>
      <attachid>67750</attachid>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2012-01-12 19:43:11 +0000</bug_when>
    <thetext>Created attachment 67750
quick and dirty patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1213713</commentid>
    <comment_count>10</comment_count>
      <attachid>67750</attachid>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2012-01-12 19:54:57 +0000</bug_when>
    <thetext>Comment on attachment 67750
quick and dirty patch

Okay here&apos;s a quick and dirty patch to fix this. The patch is against the source code for Ubuntu 11.10 package kdepimlibs version 4:4.7.3-0ubuntu0.1.

I say &quot;quick and dirty&quot; because all it does is remove all occurrences of the &apos;$SENT&apos; flat when it appears in the clients APPEND command. This is obviously not ideal as it means the flag is removed for all IMAP servers, even those where its use would have been okay. If someone has time to dig into the Akonadi logic a better solution would be to check the flags allowed by the IMAP server&apos;s folder which it is appending messages to and allow only those flags. It possibly should also translate &apos;$SENT&apos; to &apos;$MDNSent&apos; where appropriate.

I modified the method AppendJob::doStart() in the file kdepimlibs-4.7.3/kimap/appendjob.cpp.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1214212</commentid>
    <comment_count>11</comment_count>
    <who name="Will Stephenson">wstephenson</who>
    <bug_when>2012-01-13 21:28:15 +0000</bug_when>
    <thetext>Could this be related to bug 291332? Reassigning to kmail2 as per Kevin&apos;s comment on 291332 that the imap resource just passes through the flags given to it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1215045</commentid>
    <comment_count>12</comment_count>
    <who name="Paul Crook">paul_crook</who>
    <bug_when>2012-01-16 13:06:47 +0000</bug_when>
    <thetext>Looks like it might be the same problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1251542</commentid>
    <comment_count>13</comment_count>
    <who name="themroc">rauchweihe</who>
    <bug_when>2012-05-02 18:26:05 +0000</bug_when>
    <thetext>I have a similar problem since Kubuntu 11.10 on my aim.com (aol mail account): 

After sending a mail, Kmail2 failed to copy this mail in the sent IMAP Folder: 
&quot;server replied: A000035 No append failed&quot; 

SMTP with smtp.aim.com and Port 587, TLS. Kmail 4.7.3 on Kubuntu 11.10 amd64</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322576</commentid>
    <comment_count>14</comment_count>
    <who name="themroc">rauchweihe</who>
    <bug_when>2012-12-09 21:31:25 +0000</bug_when>
    <thetext>Same Problem in Kubuntu 12.10 with KDE 4.9.4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1355034</commentid>
    <comment_count>15</comment_count>
    <who name="Wolf Behrenhoff">wolf.behrenhoff</who>
    <bug_when>2013-03-27 21:35:00 +0000</bug_when>
    <thetext>I&apos;ve got the same problem. It is still present in KDE 10.1. 

I just got:
Append failed, server replied: A000373 BAD Protocol Error: Specified set of flags is not valid.
Append failed, server replied: A000201 BAD Protocol Error: Specified set of flags is not valid.

What can I do about these messages? What are they telling me? Does KMail treat this problem correctly or does it just store the message without any flags? The point is, as a user I do not want to see this message 100 times a day, in fact I do not want to see it at all - or only once with a more useful message like &quot;Your IMAP server does not support (explanation what the flags are for). This has the following impact ... [OK]&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395144</commentid>
    <comment_count>16</comment_count>
    <who name="Carlo Alberto Sanjust">tmp_prince-promo</who>
    <bug_when>2013-09-04 14:48:21 +0000</bug_when>
    <thetext>Probably related to: https://bugs.kde.org/show_bug.cgi?id=291332</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1399929</commentid>
    <comment_count>17</comment_count>
    <who name="Andre Woebbeking">woebbeking</who>
    <bug_when>2013-09-27 20:22:06 +0000</bug_when>
    <thetext>Git commit c561149538336804f212f5a12ea6cf3d1a3a19f5 by Andre Woebbeking.
Committed on 27/09/2013 at 20:19.
Pushed by woebbe into branch &apos;KDE/4.11&apos;.

Don&apos;t bother IMAP servers with not supported flags

Created a new method ResourceTask::fromAkonadiToSupportedImapFlags() to convert
Akonadi to IMAP flags supported by the server and use it everywhere instead of 
fromAkonadiFlags(). 

fromAkonadiFlags() was made private to make it impossible to call it by accident.
Related: bug 287356
FIXED-IN: 4.11.3
REVIEW:112724

This also reduces the risk to trigger 287356 as the insert on the IMAP server
doesn&apos;t fail due to unsupported IMAP flags.

M  +1    -1    resources/imap/additemtask.cpp
M  +2    -2    resources/imap/changeitemsflagstask.cpp
M  +2    -15   resources/imap/changeitemtask.cpp
M  +21   -0    resources/imap/resourcetask.cpp
M  +5    -0    resources/imap/resourcetask.h

http://commits.kde.org/kdepim-runtime/c561149538336804f212f5a12ea6cf3d1a3a19f5</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>67750</attachid>
            <date>2012-01-12 19:43:11 +0000</date>
            <delta_ts>2012-01-12 19:54:57 +0000</delta_ts>
            <desc>quick and dirty patch</desc>
            <filename>kdepimlibs.patch</filename>
            <type>text/plain</type>
            <size>1897</size>
            <attacher name="Paul Crook">paul_crook</attacher>
            
              <data encoding="base64">ZGlmZiAtTmF1ciBrZGVwaW1saWJzLm9yaWdpbmFsLy9rZGVwaW1saWJzLTQuNy4zL2RlYmlhbi9j
aGFuZ2Vsb2cga2RlcGltbGlicy5wYXRjaGVkLy9rZGVwaW1saWJzLTQuNy4zL2RlYmlhbi9jaGFu
Z2Vsb2cKLS0tIGtkZXBpbWxpYnMub3JpZ2luYWwvL2tkZXBpbWxpYnMtNC43LjMvZGViaWFuL2No
YW5nZWxvZwkyMDExLTEyLTA5IDAzOjEwOjI2LjAwMDAwMDAwMCArMDAwMAorKysga2RlcGltbGli
cy5wYXRjaGVkLy9rZGVwaW1saWJzLTQuNy4zL2RlYmlhbi9jaGFuZ2Vsb2cJMjAxMi0wMS0xMiAx
NjoyODowMC4wMDAwMDAwMDAgKzAwMDAKQEAgLTEsMyArMSwxMiBAQAora2RlcGltbGlicyAoNDo0
Ljc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