When an email is being sent to a computer, the DATA section of the message always ends with the character sequence <CRLF>.<CRLF> (see RFC 2821 and a related post). When decoding an email message in python, there is a convenient function to get the payload of the message via Message.get_payload() (package email). But this ‘payload’ still contains the <CRLF>.<CRLF> sequence, which is suppressed when looking at emails with e.g. gmail.
My question: Is there a convenient function in python to get the REAL message, in which the additional characters are cut away? Or do I need to do some hack myself?
How about just doing this (assuming it isn’t a multipart message):
In an example:
If it is only the
<CRLF>‘s you’re worried about, then it doesn’t get much cleaner than this. You might wrap it in a function to make it self-documenting, but to me this certainly beats including a custom library.