Parsing forwarded emails

前端 未结 4 1619
半阙折子戏
半阙折子戏 2021-01-11 23:27

I\'m writing some code to parse forwarded emails. What I\'m not sure is if maybe there is some Python library, some RFC I could stick to or some other resou

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-11 23:42

    In my experience just about ever email client forwards/replies differently. Typically you'll have a plain text version and a html encoded version in the mime at the bottom of the mail pack. Mail headers do have a RFC (http://www.faqs.org/rfcs/rfc2822.html "2822"), but unfortunately the content of the message body is out side the scope.

    Not only do you have to contend with the mail client variance, but the variance of user preferences. As an example: Lotus Notes puts replies at the top and Thunderbird replies at the bottom. So when a Thunderbird user is replying to a Lotus Notes user's reply they might insert their reply at the top and leave their signature at the bottom.

    Another pitfall maybe contending with word wrapping of replied chains.

    >>>> The outer reply that goes over the limit and is word wraped by
    the middle replier's mail client\n
    >> The message body of a middle reply
    > Previous reply
    Newest reply

    I wouldn't parse the message and leave it to the user to parse in their heads. Or, I'd borrow the code from another project.

提交回复
热议问题