mirror of
https://github.com/simple-login/app.git
synced 2025-02-25 08:13:16 +08:00
fix spamassassin: add ending linebreak
This commit is contained in:
parent
1ab9c926dd
commit
98a9e88ce4
1 changed files with 10 additions and 4 deletions
|
@ -1206,17 +1206,23 @@ async def handle(envelope: Envelope, smtp: SMTP) -> str:
|
||||||
|
|
||||||
|
|
||||||
async def get_spam_score(message: Message) -> float:
|
async def get_spam_score(message: Message) -> float:
|
||||||
LOG.d("get spam score")
|
sa_input = message.as_bytes()
|
||||||
|
|
||||||
|
# Spamassassin requires to have an ending linebreak
|
||||||
|
if not sa_input.endswith(b"\n"):
|
||||||
|
LOG.d("add linebreak to spamassassin input")
|
||||||
|
sa_input += b"\n"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# wait for at max 10s
|
# wait for at max 10s
|
||||||
response = await asyncio.wait_for(
|
response = await asyncio.wait_for(
|
||||||
aiospamc.check(message, host=SPAMASSASSIN_HOST), timeout=10
|
aiospamc.check(sa_input, host=SPAMASSASSIN_HOST), timeout=10
|
||||||
)
|
)
|
||||||
return response.headers["Spam"].score
|
return response.headers["Spam"].score
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
LOG.warning("SpamAssassin timeout. %s", message)
|
LOG.warning("SpamAssassin timeout on: %s", message)
|
||||||
# return a negative score so the message is always considered as ham
|
# return a negative score so the message is always considered as ham
|
||||||
return -1
|
return -999
|
||||||
|
|
||||||
|
|
||||||
class MailHandler:
|
class MailHandler:
|
||||||
|
|
Loading…
Reference in a new issue