def split_mailbox(mailbox, return_extension=False):
    """Try to split an address into parts (local part and domain name).

    If return_extension is True, we also look for an address extension
    (something foo+bar).

    :return: a tuple (local part, domain<, extension>)

    """
    domain = None
    if "@" not in mailbox:
        localpart = mailbox
    else:
        parts = mailbox.split("@")
        if len(parts) == 2:
            localpart = parts[0]
            domain = parts[1]
        else:
            domain = parts[-1]
            localpart = "@".join(parts[:-1])
    if not return_extension:
        return (localpart, domain)
    extension = None
    if "+" in localpart:
        localpart, extension = localpart.split("+", 1)
    return (localpart, domain, extension)