ssoma-mda: Handle Subject:s that aren't RFC-2047-encoded too
If the string is not RFC-2047 encoded, the charset from decode_header
is None:
>>> import email.header
>>> email.header.decode_header('hello')
[('hello', None)]
so str(decoded, charset) will fail with:
TypeError: str() argument 2 must be str, not None
Avoid that by checking charset before attempting to decode with
charset. Since that's a bit awkward, pull it out into its own
_decode_header function.
The Simonsen example is from RFC 2047 [1].
[1]: http://tools.ietf.org/html/rfc2047#section-8