コード例 #1
0
ファイル: ccs_email.py プロジェクト: libzz/amiral
def verifyEmailDomain(details):
    """
    Verify all fields related to an email domain raises
    an exception on an invalid field
    """
    from ccs_billing import verifyCustomerID
    # These are strict matchs as they will be used on the customer interface
    email = re.compile("^([a-z]([a-z0-9][a-z0-9._]?)*[a-z0-9]@" \
        "[a-z0-9]+\.([a-z0-9][a-z0-9.]?)*[a-z0-9])?$")
    domain = re.compile("^([a-z0-9]+\.([a-z0-9][a-z0-9.]?)*[a-z0-9])?$")

    # Check customer ID
    if 'customer_id' in details.keys():
        verifyCustomerID(details["customer_id"])
    else:
        raise ccs_email_error("Customer ID must be supplied")

    #Check domain and emails
    if 'domain' in details.keys() and len(details['domain']) > 1:
        if domain.match(details["domain"]) == None:
            raise ccs_email_error("Invalid domain")
    else:
        raise ccs_email_error("Domain must be supplied")

    if "catchall" in details.keys() and \
        email.match(details["catchall"]) == None:
        
        raise ccs_email_error("Invalid catchall email address")

    if "redirect" in details.keys() and \
        domain.match(details["redirect"]) == None:
        raise ccs_email_error("Invalid redirect email address")

    return
コード例 #2
0
ファイル: ccs_email.py プロジェクト: libzz/amiral
def getCustomersMailboxes(session_id, customer_id):
    from ccs_billing import verifyCustomerID
    """
    Retrieve a list of all email accounts that are ownedby a
    particular customer.
    If the customer does not exist it will raise an exception
    """
    session = getSessionE(session_id)
    
    verifyCustomerID(customer_id)
    sql = "SELECT * FROM v_mailboxes WHERE customer_id=%s"
    res = session.query(sql, (customer_id))
    
    return res
コード例 #3
0
ファイル: ccs_email.py プロジェクト: libzz/amiral
def verifyMailbox(details):
    """
    Verify all email account related fields.
    Raise exceptions if a field is not valid
    """
    from ccs_billing import verifyCustomerID
    # These are strict matchs as they will be used on the customer interface
    email = re.compile("^([a-z]([a-z0-9][a-z0-9._]?)*[a-z0-9]@" \
        "[a-z0-9]+\.([a-z0-9][a-z0-9.]?)*[a-z0-9])?$")

    # Check customer ID
    if 'customer_id' in details.keys():
        verifyCustomerID(details["customer_id"])
    else:
        raise ccs_email_error("Customer ID must be supplied")
    
    # Check domain exists
    if 'domain' in details.keys() and len(details['domain']) > 1:
        verifyDomain(details["domain"])
    else:
        raise ccs_email_error("Domain must be supplied")
    
    # Check that the username and domain combined are valid
    if 'username' in details.keys():
        if email.match("%s@%s" % (details['username'], details['domain'])) \
            == None:
            raise ccs_email_error("Invalid username")
    else:
        raise ccs_email_error("Username must be supplied")

    # Check quota if it exists
    if "quota" in details.keys() and len(details['quota']) > 1:
        # Check it's numeric
        try:
            quota_id = int(details['quota'])
        except ValueError:
            raise ccs_email_error("Quota must be numeric!")
    
    # Check forward to address
    if "fwdto" in details.keys() and \
        email.match(details["fwdto"]) == None:
        
        raise ccs_email_error("Invalid forward-to email address")

    return