Mysterious characters at the end of E-Mail, received with socket in python

与世无争的帅哥 提交于 2019-12-12 03:27:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!