Function to convert and email Message to flat string format
    :param msg: email.Message to be converted to string
    :param header_len: the msx length of the header per line
    :return: the byte string representation of the email message

def mime_to_bytes(msg, header_len):
    """
    Function to convert and email Message to flat string format
    :param msg: email.Message to be converted to string
    :param header_len: the msx length of the header per line
    :return: the byte string representation of the email message
    """
    fp = BytesIO()
    g = BytesGenerator(fp, maxheaderlen=header_len)
    g.flatten(msg)
    return fp.getvalue()