'str' object has no attribute 'decode'. Python 3 error?
You are trying to decode an object that is already decoded. You have a
str, there is no need to decode from UTF-8 anymore.
Simply drop the
header_data = data
As for your
fetch() call, you are explicitly asking for just the first message. Use a range if you want to retrieve more messages. See the documentation:
The message_set options to commands below is a string specifying one or more messages to be acted upon. It may be a simple message number (
'1'), a range of message numbers (
'2:4'), or a group of non-contiguous ranges separated by commas (
'1:3,6:9'). A range can contain an asterisk to indicate an infinite upper bound (