问题
I am not sure if this is the right forum to ask, but I give it a try.
A device is sending an E-Mail to my code in which I am trying to receive the email via a socket in python, and to decode the E-Mail with Messsage.get_payload()
calls. However. I always have a \n.\n
at the end of the message.
If the same device send the same message to a genuine email client (e.g. gmail), I get the correct original message without the \n.\n
.
I would like to know what it is with this closing set of special characters in SMTP/E-Mail handling/sending, and how to encode it away.
回答1:
As you would have seen if you looked up the SMTP protocol definition, a DATA section of a message transfer ends with <CRLF>.<CRLF>
.
回答2:
These are simply newline characters. In GMail they'll be processed and "displayed" so you don't see them. But they are still part of the email text message so it makes sense that get_payload()
returns them.
来源:https://stackoverflow.com/questions/13108615/mysterious-characters-at-the-end-of-e-mail-received-with-socket-in-python