You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2018-04-21.19:10:03.702>labels= ['3.8', 'type-feature', 'library']
title='Add a method to move messages to IMAPlib'updated_at=<Date2021-09-19.23:36:53.735>user='https://github.com/mcepl'
I am in the process of writing script working with IMAP first time using Python 3 for it (unfortunately, most of servers where I run other code is so ancient that even Python 2.7 is a stretch), and it is really nice experience so far. Many problems which are dealt with on the StackExchange with arcane workarounds are now resolved in email or imaplib libraries. Thank you, everybody!
However, it seems to me that few higher level commands could greatly improve useability of imaplib library. For example, moving messages (not fault of imaplib) is still horrible mess. In the end I had to write this monstrosity just to make moving messages working:
It would be nice if some capabilities detection (see bpo-18921) was embedded into login method, and if some version of move_messages was included in imaplib itself.
See also bpo-33336: [imaplib] MOVE is a legal command.
frispete commented on Jul 3, 2020
frispetemannequin
Mannequin
More actions
If I'm not mistaken, this is applied to the openSUSE TW version of Python.
For some reason, this seems to not play well with <instance>.uid('move',...)
on a cyrus imap server (v2.4.19). Is that to be expected?
2020-07-03 18:04:05 INFO: [imap_reorg] move b'10399' from 2017-01-01 06:30:35+02:00 to INBOX.2017
Traceback (most recent call last):
File "./imap_reorg.py", line 431, in <module>
sys.exit(main())
File "./imap_reorg.py", line 425, in main
return process()
File "./imap_reorg.py", line 133, in trace_and_call
result = func(*args, **kwargs)
File "./imap_reorg.py", line 358, in process
ret |= reorg.run_expr(expr)
File "./imap_reorg.py", line 345, in run_expr
return method(*args)
File "./imap_reorg.py", line 328, in yearly
ret = self.imap.uid('move', uid, dest)
File "/usr/lib64/python3.8/imaplib.py", line 881, in uid
typ, dat = self._simple_command(name, command, *args)
File "/usr/lib64/python3.8/imaplib.py", line 1205, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/usr/lib64/python3.8/imaplib.py", line 1030, in _command_complete
raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: UID command error: BAD [b'Unrecognized UID subcommand']
mcepl commented on Jul 3, 2020
mceplmannequin
MannequinAuthor
More actions
no this has not been included anywhere, just in the unfinished PR on GitHub
only thing which I was fighting to get into Python (and I did) was https://bugs.python.org/issue33336 but that’s another issue (without this whole discussion here would not be even possible), it is now part of the upstream Python
are you certain that the IMAP server in question supports MOVE command? (have you noticed all that business with CAPABILITIES and particularly the UID one?)
mcepl commented on Jul 3, 2020
mceplmannequin
MannequinAuthor
More actions
Sorry, UIDPLUS capability.
mcepl commented on Sep 19, 2021
mceplmannequin
MannequinAuthor
More actions
Hans-Peter Jansen (frispete)
imaplib.error: UID command error: BAD [b'Unrecognized UID subcommand']
Activity
mcepl commentedon Apr 21, 2018
I am in the process of writing script working with IMAP first time using Python 3 for it (unfortunately, most of servers where I run other code is so ancient that even Python 2.7 is a stretch), and it is really nice experience so far. Many problems which are dealt with on the StackExchange with arcane workarounds are now resolved in email or imaplib libraries. Thank you, everybody!
However, it seems to me that few higher level commands could greatly improve useability of imaplib library. For example, moving messages (not fault of imaplib) is still horrible mess. In the end I had to write this monstrosity just to make moving messages working:
It would be nice if some capabilities detection (see bpo-18921) was embedded into login method, and if some version of move_messages was included in imaplib itself.
vstinner commentedon Jul 19, 2018
See also bpo-33336: [imaplib] MOVE is a legal command.
frispete commentedon Jul 3, 2020
If I'm not mistaken, this is applied to the openSUSE TW version of Python.
For some reason, this seems to not play well with <instance>.uid('move',...)
on a cyrus imap server (v2.4.19). Is that to be expected?
mcepl commentedon Jul 3, 2020
mcepl commentedon Jul 3, 2020
Sorry, UIDPLUS capability.
mcepl commentedon Sep 19, 2021
You missed the fix for https://bugs.python.org/issue33336
gh-77508: Add imaplib.IMAP4.move method (GH-153121)
serhiy-storchaka commentedon Jul 5, 2026
Added
imaplib.IMAP4.move()in GH-153121, a wrapper for theMOVEcommand (RFC 6851).uid('MOVE', ...)works as well.