将 Base64 编码的邮件主题转换为文本
开始编写一个简单的 procmail 食谱,如果在主题中发现文本“未配置”,它将把邮件转发给我。
:0:
* ^Subject:.*Unprovisioned.*
! [email protected]
不幸的是,来自邮件服务器的邮件消息中的主题字段采用 MIME 编码字语法。
形式为:"=?charset?encoding?encoded text?=".
Subject: =?UTF-8?B?QURWSVNPUlk6IEJNRFMgMTg0NSwgTkVXIFlPUksgLSBVbnByb3Zpc2lvbmVkIENvbm4gQQ==?=
=?UTF-8?B?bGVydA==?=
上面的主题是utf-8字符集,base64编码,文本折叠成两行。所以想知道是否有任何机制/脚本/实用程序来解析它并转换为字符串格式,以便我可以应用我的 procmail 过滤器。当然,我可以编写一个 perl 脚本来解析它并执行所需的验证,但如果可能的话,希望避免它。
Set out to write a simple procmail recipie that would forward the mail to me if it found the text "Unprovisioned" in the subject.
:0:
* ^Subject:.*Unprovisioned.*
! [email protected]
Unfortunately the subject field in the mail message coming from the mail server was in MIME encoded-word syntax.
The form is: "=?charset?encoding?encoded text?=".
Subject: =?UTF-8?B?QURWSVNPUlk6IEJNRFMgMTg0NSwgTkVXIFlPUksgLSBVbnByb3Zpc2lvbmVkIENvbm4gQQ==?=
=?UTF-8?B?bGVydA==?=
The above subject is utf-8 charset, base64 encoding with text folded to two lines. So was wondering if there are any mechanisms/scripts/utilities to parse this and convert to string format so that I could apply my procmail filter. Ofcourse I can write a perl script to parse this an perform the required validations, but looking to avoid it if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Encode::MIME::Header,随 Perl 一起提供,可直接通过 Encode 访问:
Encode::MIME::Header, which ships with Perl, accessed directly through Encode: