Parsing forwarded emails

前端 未结 4 1662
半阙折子戏
半阙折子戏 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:49

    As the other answers already indicate: there is no standard, and your program is not going to be flawless.

    You could have a look at the headers, in particular the User-Agent header, to see what kind of client was used, and code specifically for the most common clients.

    To find out what clients you should consider to support, have a look at this popularity study. Various Outlooks, Yahoo!, Hotmail, Mail.app, iPhone mail, Gmail and Lotus Notes rank highly. About 11% of the mail is classified as "undetectable", but using headers from the forwarded e-mail you might be able to do better than that. Note that the statistics were gathered by placing an image inside the e-mail, so results may be skewed.

    Another problem is HTML mail, which may or may not include a plain-text version. I'm not sure about clients' usual behaviour in this respect.

提交回复
热议问题