import logging


def extract_alias_key(str):
    """
    Attempt to extract the e-mail address part of:
    PrimarySmtpAddress : aarne.bertta@futurice.com
    returns lowercase string
    """
    str_split = [val.strip() for val in str.split(":")]

    if len(str_split) != 2 or str_split[0] != u"PrimarySmtpAddress":
        logging.error("String '%s' doesn't look like a PrimarySmtpAddress value. Split value: %s" % (str, str_split))
        return None
    
    return str_split[1].lower()