Fix a bug with blocked domains filter
This commit is contained in:
@@ -41,6 +41,8 @@ BLOCK_KEYWORDS = [
|
||||
]
|
||||
|
||||
BLOCK_DOMAINS = [
|
||||
'customeriomail.com',
|
||||
'mailgun.net'
|
||||
]
|
||||
|
||||
ALLOW = [
|
||||
@@ -134,14 +136,15 @@ def filter_message(self, message):
|
||||
|
||||
# junk messages from blocked domains
|
||||
for domain in BLOCK_DOMAINS:
|
||||
if domain in message_from:
|
||||
if domain in normalized_from:
|
||||
is_spam = True
|
||||
break
|
||||
if search_headers(domain):
|
||||
if search_headers(domain, headers):
|
||||
is_spam = True
|
||||
break
|
||||
if is_spam:
|
||||
self._log_result(message, 'junking spam from blocked domain')
|
||||
message.move(self._folders['Junk Email'])
|
||||
return
|
||||
|
||||
# junk known spam headers
|
||||
@@ -175,6 +178,5 @@ def search_headers(search, headers):
|
||||
is_found = False
|
||||
for header in headers:
|
||||
for val in header.values():
|
||||
print(f"is {search} in {val}?")
|
||||
if search in val:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user