Reputation: 91
I am trying to copy a mail using the copy command.
imapper.copy(email.uid, 'TEST')
email.uid = the uid in this case 1069
TEST = the map the mail should be in
This is my copy function:
def copy(self, uid, to):
#typ, content = self._mailer.copy(bytes(uid), to)
print (uid)
typ, content = self._mailer.uid('copy', bytes(1069), 'TEST')
if typ == 'OK':
mail = _parse_email(content, include_raw=include_raw)
return mail
else:
raise Exception("Could not copy email.")
Since I'm having this error i decided to NOT use variables and hardcode it until it works and than replace it with the variables.
typ, content = self._mailer.uid('copy', bytes(1069), 'TEST')
This returns the error:
UID command error:BAD [b'Could not parse command']
I have added bytes() otherwise i get this error:
TypeError: can't concat int to bytes
Upvotes: 2
Views: 4097
Reputation: 11000
It takes a string. use str(1069) or '1069', not an integer. Although, they are numbers, the protocol treats them as strings, not numbers.
bytes(1069)
in python creates a byte array of 1069 zeros, and so you're sending a bunch of nulls.
Upvotes: 2
Reputation: 91
Okay so this is my solution:
I've added the bytes UID to the mail object and changed the copy function to use this bytes uid. This solved all problems
I've also made a fork of the easyimap wrapper with my implentations
So with a new feature to copy mails to another mailbox
https://github.com/UGxMvH/easyimap
Upvotes: 0