Bug 367708 - [Exchange 2013] Saving sent mail to IMAP folder: A000007 BAD Command Argument Error. 12 on UID STORE without parameters
Summary: [Exchange 2013] Saving sent mail to IMAP folder: A000007 BAD Command Argument...
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: IMAP resource (show other bugs)
Version: 5.2.0
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Christian Mollekopf
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-23 09:44 UTC by Martin Steigerwald
Modified: 2017-01-07 12:44 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.4.1
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Steigerwald 2016-08-23 09:44:55 UTC
After I sent a mail I receive the notifications:

Speichern fehlgeschlagen, die Serverantwort lautet: A000007 BAD Command Argument Error. 12

sometimes also after that:

Die Verbindung zum Server ist abgebrochen.

The mails are saved nonetheless.

Setup is Akonadi/KMail 4:16.04.3-2 from Debian unstable with Exchange 2013 behind Nginx proxy. Akonadi/KMail is configured to store sent mail in IMAP folder on that account.

Reproducible: Always

Steps to Reproduce:
1. Have Exchange 2013, probably behind Nginx proxy.
2. Setup IMAP and SMTP.
3. Set it up to store sent mails in folder "Sent Items."
4. Send a mail.

Actual Results:  
After I sent a mail I receive the notifications:

Speichern fehlgeschlagen, die Serverantwort lautet: A000007 BAD Command Argument Error. 12 => Saving failed, server answer is: …

sometimes also after that:

Die Verbindung zum Server ist abgebrochen. => Connection to server aborted.

In ~/xsession-errors I also get:

kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/smtp.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/smtp.so'
Cannot pause an inactive timer
"Der Name des Hosts ist keiner aus der Liste der für dieses Zertifikat gültigen Hosts" => THe name of the host is in not from the list of the hosts that are valid for this certificate.
log_kimap: We asked for UID but the server didn't give it back, resultingFlags not stored.
log_imapresource: Flag append failed:  "Speichern fehlgeschlagen, die Serverantwort lautet: A000007 BAD Command Argument Error. 12 " => Saving failed, server answer is: …
log_imapresource: Flag remove failed:  "Speichern fehlgeschlagen, die Serverantwort lautet: A000008 BAD Command Argument Error. 12 "
Database "akonadi" opened using driver "QMYSQL"

And sometimes instead:

log_kimap: We asked for UID but the server didn't give it back, resultingFlags not stored.
log_imapresource: Flag append failed:  "Speichern fehlgeschlagen, die Serverantwort lautet: A000011 BAD Command Argument Error. 12 "
log_imapresource: Flag remove failed:  "Die Verbindung zum Server ist abgebrochen." => Connection to server aborted.
"Der Name des Hosts ist keiner aus der Liste der für dieses Zertifikat gültigen Hosts"
kdeinit5: PID 8816 terminated.
kdeinit5: PID 8822 terminated.

(not sure whether the last two are related)


Expected Results:  
No error message and no occasional connection abort.
Comment 1 Martin Steigerwald 2016-08-23 10:14:19 UTC
I intend to try to access Exchange server directly instead of by proxy to determine whether its a proxy issue.

I also created IMAP log. Here is what I think the relevant excerpt of it:

C: A000022 SELECT "INBOX"
S: * 380 EXISTS
S: * 0 RECENT
S: * FLAGS ( \Seen \Answered \Flagged \Deleted \Draft $MDNSent )
S: * OK Permanent flags [ PERMANENTFLAGS ( \Seen \Answered \Flagged \Deleted \Draft $MDNSent )  ]
S: * OK Is the first unseen message [ UNSEEN 251  ]
S: * OK UIDVALIDITY value [ UIDVALIDITY 14  ]
S: * OK The next unique identifier value [ UIDNEXT 21544  ]
S: A000024 OK SELECT completed. [ READ-WRITE  ]
C: A000025 APPEND "Sent Items" (\Seen) "23-Aug-2016 10:02:29 +0000" {464}
S: + Ready for additional command text.
C: From: Martin Steigerwald <[…]@teamix.de>
To: Martin <[…]@teamix.de>
Subject: Testmail
Date: Tue, 23 Aug 2016 12:02:29 +0200
Message-ID: <1732774.ZES84pjKtC@merkaba>
Organization: teamix GmbH
X-KMail-Identity: […]
X-KMail-Dictionary: de
User-Agent: KMail/5.2.3 (Linux/4.8.0-rc2-tp520-btrfstrim+; KDE/5.23.0; x86_64; ; )
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
S: A000025 OK APPEND completed. [ APPENDUID 11 2420  ]
C: A000026 SELECT "Sent Items"
S: * 2379 EXISTS
S: * 1 RECENT
S: * FLAGS ( \Seen \Answered \Flagged \Deleted \Draft $MDNSent )
S: * OK Permanent flags [ PERMANENTFLAGS ( \Seen \Answered \Flagged \Deleted \Draft $MDNSent )  ]
S: * OK Is the first unseen message [ UNSEEN 1921  ]
S: * OK UIDVALIDITY value [ UIDVALIDITY 11  ]
S: * OK The next unique identifier value [ UIDNEXT 2421  ]
S: A000026 OK SELECT completed. [ READ-WRITE  ]
C: A000027 UID STORE 2420 +FLAGS (\Seen)
S: * 2379 FETCH ( FLAGS (\Seen \Recent) )
S: A000027 OK STORE completed.
C: A000028 UID STORE 2420
S: A000028 BAD Command Argument Error. 12
C: A000029 UID STORE 2420
S: A000029 BAD Command Argument Error. 12
C: A000030 SELECT "INBOX"
S: * 381 EXISTS
S: * 0 RECENT
S: * FLAGS ( \Seen \Answered \Flagged \Deleted \Draft $MDNSent )
S: * OK Permanent flags [ PERMANENTFLAGS ( \Seen \Answered \Flagged \Deleted \Draft $MDNSent )  ]
S: * OK Is the first unseen message [ UNSEEN 251  ]
S: * OK UIDVALIDITY value [ UIDVALIDITY 14  ]
S: * OK The next unique identifier value [ UIDNEXT 21545  ]

It seems either proxy or Exchange does not like the additional UID STORE commands. Why Akonadi issues UID STORE mutiple times (I am no expert of IMAP protocol).
Comment 2 Mikhail Krasilnikov 2016-08-29 08:01:58 UTC
I have something similar. We using Exchange without any proxies.
Comment 3 Daniel Vrátil 2017-01-07 12:44:45 UTC
Git commit 1302bbba09461574c57c8e21c740e3f157b4527c by Daniel Vrátil.
Committed on 07/01/2017 at 12:37.
Pushed by dvratil into branch 'Applications/16.12'.

IMAP: don't start STORE job with no flags

fromAkonadiToSupportedImapFlags() can filter out all the flags that we
are trying to append/remove which leads to UID STORE command with not
FLAGS attributes, which is not RFC conformant and is rejected by some
servers.
FIXED-IN: 5.4.1

M  +25   -10   resources/imap/changeitemsflagstask.cpp

https://commits.kde.org/kdepim-runtime/1302bbba09461574c57c8e21c740e3f157b4527c