def check(self, message): ip = message['client_address'] client_name = message.get('client_name', None) try: try: res = self.countryOK(ip) except socket.error: return response.DataError( 'something was wrong with the provided ip address') if res is False: try: ips = dnscache.getIpForName(client_name) except dnscache.DNSCacheError: return response.ResponseContinue() except IndexError: return response.ResponseContinue() if ip not in ips: return response.ResponseContinue() # XXX: Where is the end of the code ??? # XXX: Where are we blocking the message ?? except Exception, e: print e.__class__, e.message return response.InternalError()
def check(self, message): recipient = message['recipient'] sender = message.get('sender', '') # bounce mail can not be whitelisted if sender is '': return response.ResponseContinue try: user, domain = recipient.split('@') except ValueError: return response.DataError('invalid recipient email address: %s' % recipient) ldap_domains = [ d for d in self.configuration.get('ldap_domains', '').split(' ') if d ] if domain not in ldap_domains: _response = self.vmail_checkbwlist(domain, user, sender) if _response is True: return WhitelistingDomain if _response is False: return BlacklistingDomain return response.ResponseContinue
def check_rcpt (self,message): recipient = message['recipient'] client_address = message['client_address'] try: user, domain = recipient.split('@') except ValueError: return response.DataError('invalid email address: %s' % recipient) exist = self.vmchecker.exists(user,domain) or self.ldchecker.exists(user,domain) # XXX: we should not alter message message['exist'] = exist try: self.database.insert_new_ip(client_address) except self.databasepool.module.IntegrityError: # XXX: making sure the raw exists before anything pass if exist: #print add_right_update % message self.database.add_right_update(client_address) return response.ResponseContinue else: #print add_wrong_update % message self.database.add_wrong_update(client_address) return NoSuchUser('The recipient <%s> does not exist' % recipient)
def check(self, message): if self.isTraining(): return response.ResponseContinue recipient = message['recipient'] if not recipient: return response.ResponseContinue try: user, domain = recipient.split('@') except ValueError: return response.DataError('invalid email address: %s' % recipient) ip = message['client_address'] try: res = self.getBWListedIP(domain, ip) if res is True: return WhitelistingIP if res is False: return BlacklistingIP sender = message['sender'] # no sender if the mail is a bounce if not sender: return response.ResponseContinue try: sender_user, sender_domain = sender.split('@') except ValueError: return response.DataError('invalid sender email address: %s' % sender) res = self.getBWListedDomain(domain, sender_domain) if res is True: return WhitelistingDomain if res is False: return BlacklistingDomain except: return response.InternalError return response.ResponseContinue
def check(self, message): ip = message['client_address'] client_name = message['client_name'] sender = message.get('sender', '') if not sender: return response.ResponseContinue try: result, _, _ = spf.check(i=ip, s=sender, h=client_name) if self.debug: log.msg("spf %s" % str(result)) except spf.PermError: return response.DataError( 'can not perform SPF check with data ip=%s sender=%s host=%s' % (ip, sender, client_name)) except spf.TempError: return response.DataError( 'can not perform SPF check with data ip=%s sender=%s host=%s' % (ip, sender, client_name)) except spf.AmbiguityWarning: return response.Continue() except IndexError: # the spf library is buggy return response.ResponseContinue if result not in self.valid: return response.InternalError( 'The SPF library returned something unexpected %s' % str(result)) # if result in ['fail', 'softfail']: if result in [ 'fail', ]: return SPFViolation() return response.ResponseContinue
def check(self, message): recipient = message['recipient'] try: user, domain = recipient.split('@') except ValueError: return response.DataError('invalid email address: %s' % recipient) try: res = self.isUnfiltered(domain) if res is True: return UnfilteredDomain except: return response.PluginError return response.ResponseContinue