Log message headers on a hard error
When we know we need to bounce a message and [daemon]log_headers is enabled, we record up to 2.5kB of message headers at ERROR level. This could help diagnosing issues later. Also: no longer record MIME Type, Charset and Content-Transfer-Encoding, as the issues related to these properties no longer occur.
This commit is contained in:
parent
04ca103494
commit
7806d8c32a
1 changed files with 3 additions and 8 deletions
|
@ -59,8 +59,10 @@ class MailEncryptionProxy:
|
|||
|
||||
except:
|
||||
LOG.exception('Unexpected exception caught, bouncing message')
|
||||
|
||||
if conf.should_log_headers():
|
||||
LOG.info('Message headers: %s', self._extract_headers(message))
|
||||
LOG.error('Erroneous message headers: %s', self._beginning(envelope))
|
||||
|
||||
return xport.RESULT_ERRORR
|
||||
|
||||
return xport.RESULT_OK
|
||||
|
@ -78,13 +80,6 @@ class MailEncryptionProxy:
|
|||
end = min(limit, 2560)
|
||||
return e.original_content[0:end]
|
||||
|
||||
def _extract_headers(self, message: email.message.Message):
|
||||
return {
|
||||
'mime' : message.get_content_type(),
|
||||
'charsets' : message.get_charsets(),
|
||||
'cte' : message['Content-Transfer-Encoding']
|
||||
}
|
||||
|
||||
def _seconds_between(self, start_ms, end_ms) -> float:
|
||||
return (end_ms - start_ms) * 1000
|
||||
|
||||
|
|
Loading…
Reference in a new issue