import imaplib


def get_mail_by_uid(imap, uid):
    """ The full email as determined by the UID.
    
    Note: Must have used imap.select(<mailbox>) before
    running this function.

    Args:
        imap <imaplib.IMAP4_SSL>: the server to fetch

    Returns:
        Dictionary, with the keys 'flags', 'date_time', and
        'message'. Contents are self-explanatory...
    """
    data = imap.uid('fetch', uid, '(FLAGS INTERNALDATE RFC822)')[1]
    flags = " ".join([flag.decode() for flag in imaplib.ParseFlags(data[0][0])])
    date_time = imaplib.Internaldate2tuple(data[0][0])

    mail_data = {
        'flags': flags,
        'date_time': date_time,
        'message':  data[0][1],
    }

    return mail_data