From aae862167223e90151e2091eee55e1b125b7e22d Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Sun, 27 Nov 2016 15:40:04 +0100 Subject: [PATCH] actions: surround flags with parenthesis It looks that when using uid, some servers expects that the flags are surrounded by parenthesis. Else, we get this error: UID command error: BAD ['Error in IMAP command UID STORE: Flags list contains non-atoms.'] Seen also here: https://github.com/coddingtonbear/django-mailbox/commit/dad65d802c7eab86c88dca3ef466dc4c43daffc0 Signed-off-by: Olivier Matz --- imapami/actions.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/imapami/actions.py b/imapami/actions.py index 8653ea0..ae3c9ef 100644 --- a/imapami/actions.py +++ b/imapami/actions.py @@ -203,8 +203,7 @@ class ImapamiActionChangeFlag(ImapamiAction): cmd = '+FLAGS' else: cmd = '-FLAGS' - flag = '\\' + self.evaluate(self.flag, ami, - mail.msg) + flag = '(\\%s)' % self.evaluate(self.flag, ami, mail.msg) ret, msg = imap.uid("STORE", mail.item, cmd, flag) if ret != "OK": ami.logger.warning( @@ -281,7 +280,7 @@ class ImapamiActionMove(ImapamiAction): ami.logger.warning( "imap copy returned %s: %s" % (ret, str(msg))) return False - ret, msg = imap.uid("STORE", mail.item, '+FLAGS', '\\Deleted') + ret, msg = imap.uid("STORE", mail.item, '+FLAGS', '(\\Deleted)') if ret != "OK": ami.logger.warning( "imap delete returned %s: %s" % (ret, str(msg))) -- 2.39.5