Merge pull request 'Return Permanent Failure when dealing with undeliverable mail' (#162) from perm-fail-on-unencrypted into develop

Reviewed-on: #162
This commit is contained in:
pfm 2024-09-21 14:26:54 +02:00
commit c8ed650053

View file

@ -71,13 +71,17 @@ class MailEncryptionProxy:
else:
LOG.exception('Unexpected exception caught, bouncing message')
return xport.RESULT_TRANS_FAIL
return xport.RESULT_PERM_FAIL
return xport.RESULT_OK
def _send_unencrypted(self, operation, envelope: Envelope, send: xport.SendFrom):
# Do not parse and re-generate the message, just send it as it is.
send(envelope.original_content, operation.recipients())
try:
send(envelope.original_content, operation.recipients())
except:
LOG.exception('Unencrypted delivery failed, returning PERMANENT FAILURE to sender')
raise xport.PermanentFailure()
def _beginning(self, e: Envelope) -> bytes:
double_eol_pos = e.original_content.find(DOUBLE_EOL_BYTES)