return 421 if any unexpected error happen

This commit is contained in:
Son NK 2020-08-16 11:10:01 +02:00
parent 118862ead0
commit d738997c4e
1 changed files with 10 additions and 0 deletions

View File

@ -1212,6 +1212,16 @@ async def get_spam_score(message: Message) -> float:
class MailHandler:
async def handle_DATA(self, server, session, envelope: Envelope):
try:
ret = await self._handle(envelope)
return ret
except Exception:
LOG.exception(
"email handling fail %s -> %s", envelope.mail_from, envelope.rcpt_tos
)
return "421 SL Retry later"
async def _handle(self, envelope: Envelope):
start = time.time()
LOG.debug(
"===>> New message, mail from %s, rctp tos %s ",