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'}
def setUp(self): if not hasattr(self, 'server'): self.server = imapIO.connect(host, port, user, password)
# 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
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