需要使用perl解析utf8电子邮件

时间:2015-03-30 15:42:40

标签: perl email utf-8 mime-types mime

我需要解析一封似乎使用utf-8编码的电子邮件,以便将主题和发件人及身体部分拉出来。

标题部分没有问题,但正文看起来像这样:

LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0KRmVkb3JhIFVwZGF0ZSBOb3RpZmljYXRpb24KRkVET1JB
MTUtNDQ1NwoyMDE1LTAzLTIzIDAyOjM5OjI1Ci0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCgpO
ICAgICAgICA6IGtlcm5lbApQcm9kdWN0ICAgICA6IEZlZG9yYSAyMQpWZXJzaW9uICAgICA6
MTkuMgpSZWxlYXNlICAgICA6IDIwMS5mYzIxClVSTCAgICAgICAgIDogaHR0cDovL3d3dy5r
ZWwub3JnLwpTdW1tYXJ5ICAgICA6IFRoZSBMaW51eCBrZXJuZWwKRGVzY3JpcHRpb24gOgpU
Z2VybmVsIG1ldGEgcGFja2FnZQoKLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KVXBkYXRlIElu
...

Alpine显然可以正确解码它,并告诉我:

[ The following text is in the "utf-8" character set. ]
[ Your display is set for the "ANSI_X3.4-1968" character set.  ]
[ Some characters may be displayed incorrectly. ]

我可以使用哪个perl模块?希望这足以帮助。

我看到创建MIME编码消息的模块,但是如何解码和读取?我是否需要这种特定类型编码的模块?

1 个答案:

答案 0 :(得分:0)

根据评论中的内容类型,这里发生了几种编码。正文已经过Base-64编码,允许电子邮件将任意数据表示为ASCII。另一个是Base64编码下的数据是UTF-8编码。

Email::MIME这样的东西应该能够处理这个问题而不必担心细节。