Example #1
0
def getLogin():
    try:
        client = imapIO.connect(settings.HOST,
                                user=request.authorization['username'],
                                password=request.authorization['password'])
        return {'status': True, 'client': client}
    except:
        return {'status': False, 'msg': 'Error connecting host'}
Example #2
0
File: tests.py Project: vad/imapIO
 def setUp(self):
     if not hasattr(self, 'server'):
         self.server = imapIO.connect(host, port, user, password)
Example #3
0
    # Return
    return countByKey


def connect(settings):
    'Connect to IMAP server'
    try:
        imapParams = [settings[x] for x in
            'sms.imap.host', 
            'sms.imap.port', 
            'sms.imap.username', 
            'sms.imap.password']
    except KeyError, error:
        raise KeyError('Missing %s in configuration file' % error)
    try:
        imapServer = imapIO.connect(*imapParams)
    except imapIO.IMAPError, error:
        return error
    return imapServer


def processRegistration(email):
    'Process an SMS address registration'
    # Get userID and code
    match = pattern_registration.match(email.subject)
    if not match:
        return False
    userID, userCode = match.groups()
    userID = int(userID)
    fromWhom = parseaddr(email.fromWhom)[1]
    # Make sure we have a proper email address
Example #4
0
 def setUp(self):
     if not hasattr(self, 'server'):
         self.server = imapIO.connect(host, port, user, password)
Example #5
0
    imapServer.expunge()
    # Return
    return countByKey


def connect(settings):
    'Connect to IMAP server'
    try:
        imapParams = [
            settings[x] for x in 'sms.imap.host', 'sms.imap.port',
            'sms.imap.username', 'sms.imap.password'
        ]
    except KeyError, error:
        raise KeyError('Missing %s in configuration file' % error)
    try:
        imapServer = imapIO.connect(*imapParams)
    except imapIO.IMAPError, error:
        return error
    return imapServer


def processRegistration(email):
    'Process an SMS address registration'
    # Get userID and code
    match = pattern_registration.match(email.subject)
    if not match:
        return False
    userID, userCode = match.groups()
    userID = int(userID)
    fromWhom = parseaddr(email.fromWhom)[1]
    # Make sure we have a proper email address