def extract_email_headers(msg):

    msg_obj = {}
    msg_obj["from"] = {}
    from_field = msg.getheaders('From')[0]
    msg_obj["from"]["name"], msg_obj["from"]["address"] = email.utils.parseaddr(from_field)
    msg_obj["to"] = email.utils.getaddresses(msg.getheaders('To'))
    

    msg_obj["subject"] = msg.getheaders('Subject')[0]
    msg_obj["date"] = msg.getheaders('Date')[0]

    return msg_obj
Extract headers from email
dataset/ETHPy150Open khamidou/kite/src/back/kite/maildir.py/extract_email_headers