code: def canonicalize(message):
      
  
      if message.is_multipart() \
              or message.get('Content-Transfer-Encoding') != 'binary':
  
          return mime_to_bytes(message, 0).replace(
              b'\r\n', b'\n').replace(b'\r', b'\n').replace(b'\n', b'\r\n')
      else:
          message_header = ''
          message_body = message.get_payload(decode=True)
          for k, v in message.items():
              message_header += '{}: {}\r\n'.format(k, v)
          message_header += '\r\n'
          return message_header.encode('utf-8') + message_body
docs: Function to convert an email Message to standard format string
  
      :param message: email.Message to be converted to standard string
      :return: the standard representation of the email message in bytes