'Returns the email if and only if the user\'s email address is
allowed to join the realm they are trying to join.'

def clean_email(self):

    email = self.cleaned_data['email']
    if get_unique_open_realm():
        return email
    realm = self.realm
    if ((realm is None) and (not settings.REALMS_HAVE_SUBDOMAINS)):
        realm = get_realm_by_email_domain(email)
    if (realm is None):
        if settings.REALMS_HAVE_SUBDOMAINS:
            raise ValidationError(_('The    organization    you    are    trying    to    join    using    {email}    does    not    exist.').format(email=email))
        else:
            raise ValidationError(_('Your    email    address,    {email},    does    not    correspond    to    any    existing    organization.').format(email=email))
    if realm.invite_required:
        raise ValidationError(_('Please    request    an    invite    for    {email}    from    the    organization    administrator.').format(email=email))
    if (not email_allowed_for_realm(email, realm)):
        raise ValidationError(_('Your    email    address,    {email},    is    not    in    one    of    the    domains    that    are    allowed    to    register    for    accounts    in    this    organization.').format(string_id=realm.string_id, email=email))
    if realm.is_zephyr_mirror_realm:
        email_is_not_mit_mailing_list(email)
    return email
